## Installation
Install both `react-streams` and `rxjs`
```bash
npm i react-streams rxjs
```
## About
`react-streams` enables you to stream for sources or props. The stream will pass through a `pipe` and can be updated by `plans`.
### Stream from sources
**_``_** - A component that subscribes to a `source` and streams values to children. The stream will pass through a `pipe` and can be updated by `plans`.
> ```js
> {values =>
{values.message}
}
> ```
**_`stream(source)`_** - Creates a named component that subscribes to a `source` and streams values to children. The stream will pass through a `pipe` and can be updated by `plans`.
> ```js
> const MyStreamingComponent = stream(source$)
>
>
> {(values)=>
{values.message}
}
>
> ```
### Stream from props
**_``_** - A component that streams props changes to children. Changes to props will pass through the `pipe` and can be updated by `plans`.
> ```js
>
> {values =>
{values.message}
}
>
> ```
**_`streamProps()`_** - Create a named component that streams props changes to children. Changes to props will pass through the `pipe` and can be updated by `plans`.
> ```js
> const MyStreamingPropsComponent = streamProps()
>
>
> {(values)=>
{values.message}
}
>
> ```
### Stream through `pipe`
**_`pipe`_** is any operator (or `piped` combination of operators) that you want to act on your stream. Pipes can be simple mappings or complex ajax requests with timing as long as they return a function that returns an object which matches the `children`'s arguments.
> ```js
> message + "!")}>
> {values =>
{values.message}
}
>
> ```
### Make a `plan` to update
**_`plan`_** is a function that can be observed.
> ```js
> const update = plan()
>
> from(update).subscribe(value => console.log(value))
>
> update("Hello") //logs "Hello"
> update("Friends") //logs "Friends"
> ```
Pass plans to the `plans` prop to control updates to the stream.
> ```js
> const update = plan(
> map(({message})=> ({message: "Updated!"}))
> )
>
>
> {({message, update})=>
>
>
{message}
>
>
> }
>
> ```
## Examples
Enough chit-chat, time for examples!
Play with Examples at [codesandbox.io](https://codesandbox.io/s/github/johnlindquist/react-streams/tree/master/examples?module=/stream/index.js)
### ``
[Demo here](https://codesandbox.io/s/github/johnlindquist/react-streams/tree/master/examples?module=generic/index.js)
```js
import React from "react"
import { Stream } from "react-streams"
import { of, pipe } from "rxjs"
import { delay, startWith } from "rxjs/operators"
const startWithAndDelay = (message, time) =>
pipe(delay(time), startWith({ message }))
const message$ = of({ message: "Hello" })
export default () => (