Push Overview
Push Lines
are based on Observers
(which are a sub-type of Coroutines):
interface Observer<T> { next(value : T): void; return?(): void; throw?(error): void;}
Push
is used less often than Pull
and has an independent implementation. Push Lines
are not re-usable and you must close the observer
when you're done with it by calling its .return()
method. Closing the observer
also signals end-of-sequence
(many operations wait till they gather all items, until they could continue). The .throw()
method allows to cancel execution at any time.
To use Push Lines
you need to import from @undercut/push
entry point.
Terms in releation to Push Lines
:
observer
-- an object implementing theObserver protocol
.operation
-- a function taking anobserver
accepting result items and returning anobserver
accepting source items.pipeline
-- an ordered sequence (array) ofoperations
.source
-- there is no realsource
inPush Lines
, because someone need to manually put items into theobserver
, but severalpush
functions can help you to processiterables
withPush Lines
.target
-- anobserver
that will receive the result.
type PushOperation = <T, R>(observer: Observer<T>) => Observer<R>;
type PullPipeline = Array<PushOperation>;
type PushTarget = Observer<T>;