janus
janus copied to clipboard
[stdlib] Add bridge from Varying to various other common abstractions
eg: Varying.asPromise(v).succeedIf(f).failureIf(f) -> Promise
Promises, Rx Observable, anything else that's popular and semantically harmonious enough can be considered. Probably rely on peerDependencies
or dependency injection to keep our own dependencies at a minimum.
As detailed in this discussion: https://github.com/socrata-platform/janus/pull/2#discussion_r90362349
janus-stdlib now provides fromEvent(jqInstance, eventName, f)
which gives a Varying
where given an f: (event, …) -> value
will map event firings into values for the Varying
. It's implemented via Varying.managed
, which means the resource lifecycle of the event listener is correctly handled and nothing happens unless the Varying
is actually reacted against.