1.0.2 • Published 5 years ago
preact-stream-builder v1.0.2
preact-stream-builder
Inspired by flutter's StreamBuilder
, a component that render something listening a Subscribable
object.
Installation
npm install --save preact-stream-builder
Arguments
stream
: A Subscribable object.builder
: (snapshot: { data, state }) => VNodedata
: The data received from the stream subscription or theinitialData
state
: One ofactive
,done
,none
,values
,waiting
initialData
: (Optional) The data passed down to thebuilder
until the stream emit something.
Example
import { StreamBuilder } from 'preact-stream-buidler`;
<StreamBuilder
stream={interval(5000).pipe(take(4))}
initialData={'Hello wold'}
builder={({ data, state }) => (<p>{data}, {state}</p>)}
/>
License
MIT