es-observable
v2.0.5
Published
ES Observable proposal implementation
Downloads
65
Maintainers
Readme
es-observable
ES Observable proposal implementation
Install
npm install --save es-observable
or yarn add es-observable
Usage
import { Observable } from 'es-observable'
Observable.of( ... )
Observable.from( ... )
new Observable(observer => { ... })
Flow
It works good only with
[libs]
+ node_modules/es-observable/flow-typed
[lints]
in .flowconfig
.
API
import {
Observable,
type SubscriptionObserver, // Class declaration
type Subscription, // Class declaration
type Observer, // Type declaration
type ObservableCompatible, // Type declaration
type ObservableLike, // Type declaration
type SubscriptionLike, // Interface declaration
} from 'es-observable'
ObservableCompatible
import type { SymbolObservable } from 'symbol-observable'
type ObservableCompatible<T> = {
'@@observable'(): ObservableLike<T>,
}
ObservableLike
import type { SymbolObservable } from 'symbol-observable'
export type ObservableLike<T> = {
+subscribe: ((observer: Observer<T>) => SubscriptionLike<T>) &
((
onNext: (T) => mixed,
onError?: (T) => mixed,
onComplete?: () => mixed,
) => SubscriptionLike<T>),
'@@observable'(): ObservableLike<T>,
}