Hey All.
Working on my Rxjs observable bindings, Im uncovering lots of weird behavior in observables that i hope to track in types. For example, Rxjs talks about observables being “hot” or “cold” which to some degree means that the observable emits values immediately on connection. So to reflect that in types i was thinking like:
type value<'a>
type void
type observable<'first> // first is either value<'a> or void
Next there are operators that can be applied to single observables, mostly they would pass through \
firsttype but there is also
startsWith` that would produce an observable with value<'a>. There are also functions like “withLatestFrom” or “merge2” that can take multiple observables, and then the output first value is a function of two first types…
let x: observable<value<int>>
let x2: observable<value<int>>
let y: observable<void>
let mergeX = merge2(x, x2) // Will be first value<'a>
let mergeXy = merge2(x, y) // Will be void
I think I have to make separate instances of each combinator to handle the different combinations, which could work, but then there are combinators that take an array of observables…
let mergeAll = mergeAll([x, x2, y])
I think the Rescript formal answer is “dont” but…how would you do this?
I have half been wondering it polyvariants could do this if we had subtraction from pv types. Using PV like a row type would be rad.
Thanks
A