You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The library summary hasn't been written yet (contributions are welcome!). The library summary describes the library's purpose in one to three sentences.
9
+
Utilities for creating and managing push-based subscriptions, inspired by the [event](https://github.com/paf31/purescript-event) library. This library is used to implement subscriptions in [Halogen](https://github.com/purescript-halogen/purescript-halogen), but it can be used independently of Halogen.
The quick start hasn't been written yet (contributions are welcome!). The quick start covers a common, minimal use case for the library, whereas longer examples and tutorials are kept in the [docs directory](./docs).
21
+
The `halogen-subscriptions`library helps you create and transform push-based subscriptions. Most subscriptions follow this pattern:
22
22
23
-
## Documentation
23
+
1. Use the `create` function to produce a paired `Emitter` and `Listener`. An emitter is a possibly-infinite list of values that you can subscribe to, and a listener is a mechanism for pushing values to the emitter.
24
+
2. Use the `subscribe` function to subscribe to outputs from the emitter by providing a callback function to run each time a value is emitted.
25
+
3. Use the `notify` function to push values to the emitter via the listener.
26
+
4. Use the `unsubscribe` function to end a subscription to an emitter.
27
+
28
+
Here's a simple example that logs "Hello" and then "Goodbye":
24
29
25
-
`halogen-subscriptions` documentation is stored in a few places:
30
+
```purs
31
+
module Main where
26
32
27
-
1. Module documentation is [published on Pursuit](https://pursuit.purescript.org/packages/purescript-halogen-subscriptions).
28
-
2. Written documentation is kept in the [docs directory](./docs).
29
-
3. Usage examples can be found in [the test suite](./test).
33
+
import Prelude
30
34
31
-
If you get stuck, there are several ways to get help:
35
+
import Effect (Effect)
36
+
import Effect.Console as Console
37
+
import Halogen.Subscription as HS
32
38
33
-
-[Open an issue](https://github.com/purescript-halogen/purescript-halogen-subscriptions/issues) if you have encountered a bug or problem.
34
-
-[Search or start a thread on the PureScript Discourse](https://discourse.purescript.org) if you have general questions. You can also ask questions in the `#purescript` and `#purescript-beginners` channels on the [Functional Programming Slack](https://functionalprogramming.slack.com) ([invite link](https://fpchat-invite.herokuapp.com/)).
You can contribute to `halogen-subscriptions` in several ways:
45
+
HS.notify listener "Hello"
46
+
HS.notify listener "Goodbye!"
39
47
40
-
1. If you encounter a problem or have a question, please [open an issue](https://github.com/purescript-halogen/purescript-halogen-subscriptions/issues). We'll do our best to work with you to resolve or answer it.
48
+
HS.unsubscribe subscription
49
+
```
41
50
42
-
2. If you would like to contribute code, tests, or documentation, please [read the contributor guide](./CONTRIBUTING.md). It's a short, helpful introduction to contributing to this library, including development instructions.
51
+
Emitters can be combined and transformed to make more sophisticated subscriptions.
52
+
53
+
## Documentation
43
54
44
-
3. If you have written a library, tutorial, guide, or other resource based on this package, please share it on the [PureScript Discourse](https://discourse.purescript.org)! Writing libraries and learning resources are a great way to help this library succeed.
55
+
Module documentation is [published on Pursuit](https://pursuit.purescript.org/packages/purescript-halogen-subscriptions).
0 commit comments