Skip to content

Commit

Permalink
Fix: at now curried + some addition to documentation (#677)
Browse files Browse the repository at this point in the history
* link to PACKAGES.md in Readme, add @most/adapter to PACKAGES.md

* curry2 at

* doc: newStream

* Revert "curry2 at"

This reverts commit e7072a2.

* docs: newStream() example now uses a dispose function

* update signature in doc that at is not curried
  • Loading branch information
semmel authored Mar 8, 2024
1 parent 33637e8 commit 015c0a2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions PACKAGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
| [hold](https://github.com/mostjs/hold) | Deliver the most recently seen event to new observers
| [create](https://github.com/mostjs/create) | Imperatively push events into a Stream
| [dom-event](https://github.com/mostjs/dom-event) | Streamlined DOM Events
| [adapter](https://github.com/mostjs/adapter) | Imperatively put events into mostjs streams
| [examples](https://github.com/mostjs/examples) | Most.js examples

### Most Tools for Contributors
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Specifically, `@most/core` features Most's battle-tested, high-performance archi
* [API docs](https://mostcore.readthedocs.io)
* [Get it](#get-it)
* [Examples](examples)
* [Packages](PACKAGES.md)
* [Contribute](#contribute)

## Get it
Expand Down
32 changes: 31 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ at

.. code-block:: haskell
at :: Time -> a -> Stream a
at :: (Time, a) -> Stream a
at :: Time -> Stream void
Create a :ref:`Stream` containing a single event at a specific time. ::

Expand Down Expand Up @@ -318,6 +319,35 @@ Create a :ref:`Stream` that fails with the provided ``Error`` at time 0. This c

throwError(X): X

.. _newStream:

newStream
`````````

.. code-block:: haskell
newStream :: ((Sink a, Scheduler) -> Disposable) -> Stream a
Create a :ref:`Stream` from a custom event producer (i.e. :ref:`run` method).

.. code-block:: javascript
import { currentTime as ct } from '@most/scheduler'
// Number -> a -> Stream a
const valueAt = delay => value => newStream(
(sink, scheduler) => {
const publishVal = val => {
sink.event(ct(scheduler), val);
sink.end(ct(scheduler));
};
const timer = setTimeout(publishVal, delay, value);
return { dispose: () => { clearTimeout(timer); } };
}
);
valueAt(1000)(7): ---7|
Extending
^^^^^^^^^

Expand Down

0 comments on commit 015c0a2

Please sign in to comment.