omisable
Omisable - Both a Promise or an Observable, creating a single object that is both Promise-like and Observable-like
omisable
provides a hybrid class that is both a Promise and an Observable to allow consumers how to interact with your api. The Omisable class defers creation of both the Observable and Promise until they are needed.
The factory for the Observable, and optionally the Promise, allows the producer to determine if the object should be a shared instance, or a single-use object.
Getting started
In your node root, run:
npm install --save omisable
Minimal usage example:
;
It is often more efficient to provide a Promise factory as well and is one of the driving reasons this class was created. If no Promise factory is provide, as above, then it behaves similar to Rx.Observable.from(source).take(1).asPromise()
.
More Information
- docs: https://now-ims.github.io/omisable/
- github: https://github.com/now-ims/omisable
- author: https://github.com/roknow
License
MIT Licence Copyright (c) 2018