1.0.2 • Published 5 years ago

preact-stream-builder v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

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 }) => VNode
    • data: The data received from the stream subscription or the initialData
    • state: One of active, done, none, values, waiting
  • initialData: (Optional) The data passed down to the builder 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