I am trying to write a binding for Rx.js - merge operator. Basically, it is a variadic function that takes multiple observables as input and produces a new observable which is an untagged union of all the values emitted by input observables.
This is my current solution:
type 'a observable
type untagged
type anyObs = untagged observable
external merge2 : 'a observable -> 'b observable -> anyObs = "merge" [@@bs.module "rxjs"]
external merge3 : 'a observable -> 'b observable -> 'c observable -> anyObs = "merge" [@@bs.module "rxjs"]
external merge4 :
'a observable -> 'b observable -> 'c observable -> 'd observable -> anyObs = "merge"
[@@bs.module "rxjs"]
But this solution is not very elegant. The caller has to use something like Js.Types.classify later when projecting output observable.
Is this the only solution? If not, what is the formal way of doing this?