Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: at now curried + some addition to documentation #677

Merged
merged 6 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks

| [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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, the second signature is only valid for JavaScript. The TS types currently prevent calling at with just 1 argument.

Maybe we can keep only the first signature, and add a note for JavaScript users?

Suggested change
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); } };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}
);

valueAt(1000)(7): ---7|

Extending
^^^^^^^^^

Expand Down