devexperts / dx-platform

Mozilla Public License 2.0
33 stars 24 forks source link

Add Behavior type #223

Open raveclassic opened 4 years ago

raveclassic commented 4 years ago

Add the following type to rx-utils

interface Behavior<A> extends Observable<A> {
  readonly getValue: () => A;
}

so that we could use it as both a value-over-time and an Observable.

Also add typeclass instance (you can use rxjs's internal _subscribe method to deal with Observable#subscribe which cannot be overridden due to messy overloadings):

export const instance: Functor<URI> & FoldableValue<URI>  = { ... } 
export const behavior = {
  ...instance,
  ...pipeable(instance)
}