Source Location: packages/core/src/source.ts#L605 Signature Copy 1 function subscribe < T >( 2 sink ?: Sink < T > | ( ( event : Event < T >) => void ) , 3 ): ( source : Source < T >) => Sink < T >
Higher order function which takes a sink, and returns another function which receives a source that will be subscribed to using the given sink. This is useful, for example, at the end of pipe calls in order to subscribe to the transformed source.
Parameters Parameter Type Description sink Copy
The sink to be given to the received source.
Returns Type Description Copy
The higher order function which takes a source to subscribe to.
Example Usage Copy 1 import { DogPictures , myGetDogPictures } from ' ./myApi.ts ' ; 2 import { MyRequestTimeoutError } from ' ./myRequestTimeoutError.ts ' ; 3 import { myReportError } from ' ./myReportError.ts ' 4 import { myUpdateViewWithDogs } from ' ./myUpdateViewWithDogs.ts ' 5 6 const sink = Sink < DogPictures > (event => { 7 if ( event . type === ThrowType ) { 8 myReportError ( event . error ) 9 } else if ( event . type === EndType ) { 10 return ; 11 } 12 myUpdateViewWithDogs ( event . value ) 13 } ) ; 14 15 pipe ( 16 myGetDogPictures ( ... ) , 17 timeoutMs ( 5000 , throwError ( () => new MyRequestTimeoutError ())) , 18 retry ( 3 ) , 19 subscribe (sink) 20 ) ;
See Also ← isSinkall→