Skip to content

Commit

Permalink
docs(README): rebuild documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tylor Steinberger committed Oct 7, 2017
1 parent d83513d commit 77cd149
Showing 1 changed file with 105 additions and 0 deletions.
105 changes: 105 additions & 0 deletions packages/stream/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,38 @@ export { ap } from '@most/core'
<hr />


#### at\<A\>(time: Time, value: A): Stream\<A\>

<p>

Creates a stream that emits a value after a given amount of time.

</p>


<details>
<summary>See an example</summary>

```typescript

```

</details>

<details>
<summary>See the code</summary>

```typescript

export { at } from '@most/core'

```

</details>

<hr />


#### at\<A\>(time: number, value: A): Stream\<A\>

<p>
Expand Down Expand Up @@ -1857,6 +1889,79 @@ export { startWith } from '@most/core'
<hr />
#### state\<A, B\>(f: (acc: A, value: B) =\> A, seed$: Stream\<A\>, values$: Stream\<B\>): Stream\<A\>
<p>
Especially useful when keeping local state that also needs to be updated
from an outside source.
</p>
<details>
<summary>See an example</summary>
```typescript
import { Stream } from '@motorcycle/types'
import { query, dragOverEvent, dragstartEvent, dropEvent } from '@motorcycle/dom'
import { sample, map, state, mapList } from '@motorcycle/stream'
import { move } from '@typed/prelude'

export function ReorderableList(sources) {
const { list$, dom } = sources
const li = query('li', dom)
const dragOver$ = dragOverEvent(li)
const dragStart$ = dragstartEvent(li)
const drop$ = dropEvent(li)
const reducer$: Stream<(list: Array<string>) => Array<string>> =
sample((to, from) => move(from, to), map(getKey, drop$), map(getKey, dragStart$))
const reorderedList$ = state((x, f) => f(x), list$, reducer$)
// create all of our <li> tags
const childViews$ = mapList(listItem, reorderedList$)
// create our <ul> containgin our <li> tags
const view$ = map(view, childViews$)

return {
view$,
preventDefault$: dragOver$,
}
}
```
</details>
<details>
<summary>See the code</summary>
```typescript

export const state: State = curry3(__state)

function __state<A, B>(
f: (accumulator: B, value: A) => B,
seed$: Stream<B>,
values$: Stream<A>
): Stream<B> {
return switchMap(seed => scan(f, seed, values$), seed$)
}

export interface State {
<A, B>(f: (accumulator: A, value: B) => A, seed$: Stream<A>, values$: Stream<B>): Stream<A>
<A, B>(f: (accumulator: A, value: B) => A, seed$: Stream<A>): (values$: Stream<B>) => Stream<A>
<A, B>(f: (accumulator: A, value: B) => A): {
(seed$: Stream<A>, values$: Stream<B>): Stream<A>
(seed$: Stream<A>): (values$: Stream<B>) => Stream<A>
}
}

```
</details>
<hr />
#### switchCombine\<A\>(streamList$: Stream\<Array\<Stream\<A\>\>): Stream\<ReadonlyArray\<A\>\>
<p>
Expand Down

0 comments on commit 77cd149

Please sign in to comment.