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
See [here](https://github.com/robertdp/purescript-react-halo/blob/master/generated-docs/md/React.Halo.md)
33
-
34
34
## What does Halo provide?
35
35
36
36
Whether you are using the hook or one of the component helpers, the main feature that Halo provides is the `eval` function. It looks like:
@@ -51,7 +51,7 @@ data Lifecycle props action
51
51
52
52
`HaloM` is also a monad transformer, and so you can lift any monad `m` logic into `HaloM`. Just be aware that in order to run the logic, Halo requires that you `hoist` (convert) your chosen monad into `Aff` before returning it.
53
53
54
-
## Hoisting
54
+
###Hoisting
55
55
56
56
```purescript
57
57
hoist :: forall props state action m m'. Functor m => (m ~> m') -> HaloM props state action m ~> HaloM props state action m'
@@ -63,7 +63,7 @@ Example:
63
63
invertReaderT x = ReaderT \env -> Halo.hoist (flip runReaderT env) x
64
64
```
65
65
66
-
## Working with props
66
+
###Working with props
67
67
68
68
```purescript
69
69
props :: forall props action state m. HaloM props state action m props
@@ -77,13 +77,13 @@ fireOnChange value = do
77
77
onChange value
78
78
```
79
79
80
-
## Working with state
80
+
###Working with state
81
81
82
82
`HaloM` doesn't have any special interface for reading and modifying state, instead providing an instance of [MonadState](https://pursuit.purescript.org/packages/purescript-transformers/docs/Control.Monad.State.Class) for flexibility.
83
83
84
-
## Subscriptions
84
+
###Subscriptions
85
85
86
-
`HaloM` also provides functions for subscriptions management:
86
+
Subscriptions registered using these functions are automatically tracked by Halo.
87
87
88
88
```purescript
89
89
subscribe :: forall props state action m. Event action -> HaloM props state action m SubscriptionId
@@ -101,9 +101,9 @@ subscribe' :: forall m action state props. (SubscriptionId -> Event action) -> H
101
101
102
102
Any subscriptions that remain when the component is unmounted are automatically unsubscribed. This prevents requiring manual clean up in the `Finalize` lifecycle event. Also note that new subscriptions will not be created once the `Finalize` event has been fired.
103
103
104
-
##Parallelism
104
+
### Forking
105
105
106
-
And finally, `HaloM` provides functions for creating and killing forks which run in parallel (or as useful an approximation as we can get in JavaScript):
106
+
Also provided are functions for creating and killing forks which launch processes in separate "threads" (or as useful an approximation as we can get in JavaScript):
107
107
108
108
```purescript
109
109
fork :: forall m action state props. HaloM props state action m Unit -> HaloM props state action m ForkId
@@ -112,3 +112,8 @@ kill :: forall m action state props. ForkId -> HaloM props state action m Unit
112
112
```
113
113
114
114
Similarly to subscriptions, when the component unmounts all still-running forks will be killed. However new forks _can_ be created during the `Finalize` phase but there is no way of killing them (as with Halogen).
115
+
116
+
117
+
### Parallelism
118
+
119
+
Finally `HaloM` provides an instance of `Parallel` for converting back and forth between `HaloAp`, it's applicative counterpart. This allows any logic to be easily converted to run in `parallel` or `sequential`ly.
type HookSpec props state action m = { eval :: Lifecycle props action -> HaloM props state action m Unit, initialState :: state, props :: props }
7
+
```
8
+
9
+
#### `UseHalo`
10
+
11
+
```purescript
12
+
newtype UseHalo props state action hooks
13
+
= UseHalo (UseEffect Unit (UseEffect Unit (UseMemo Unit (HaloState props state action) (UseState state hooks))))
14
+
```
15
+
16
+
##### Instances
17
+
```purescript
18
+
Newtype (UseHalo props state action hooks) _
19
+
```
20
+
21
+
#### `useHalo`
22
+
23
+
```purescript
24
+
useHalo :: forall state action props. HookSpec props state action Aff -> Hook (UseHalo props state action) (state /\ (action -> Effect Unit))
25
+
```
26
+
27
+
Run renderless Halo in the current component. This allows Halo to be used with other hooks and other ways of
28
+
building components.
29
+
30
+
#### `ComponentSpec`
31
+
32
+
```purescript
33
+
type ComponentSpec props state action m = { eval :: Lifecycle props action -> HaloM props state action m Unit, initialState :: state, render :: { props :: props, send :: action -> Effect Unit, state :: state } -> JSX }
34
+
```
35
+
36
+
#### `component`
37
+
38
+
```purescript
39
+
component :: forall state action props. String -> ComponentSpec props state action Aff -> Effect (props -> JSX)
40
+
```
41
+
42
+
Build a component by providing a name and Halo component spec.
43
+
44
+
#### `component_`
45
+
46
+
```purescript
47
+
component_ :: forall state action. String -> ComponentSpec Unit state action Aff -> Effect JSX
48
+
```
49
+
50
+
Build a propless component by providing a name and Halo component spec.
Copy file name to clipboardExpand all lines: generated-docs/md/React.Halo.Internal.Eval.md
+16-3Lines changed: 16 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,36 +6,49 @@
6
6
evalHaloM :: forall props state action. HaloState props state action -> (HaloM props state action Aff) ~> Aff
7
7
```
8
8
9
+
Interprets `HaloM` into the base monad `Aff`.
10
+
9
11
#### `evalHaloF`
10
12
11
13
```purescript
12
14
evalHaloF :: forall props state action. HaloState props state action -> (HaloF props state action Aff) ~> Aff
13
15
```
14
16
17
+
Interprets `HaloF` into the base monad `Aff`, keeping track of state in `HaloState`.
18
+
15
19
#### `EvalSpec`
16
20
17
21
```purescript
18
-
type EvalSpec props action state m = { onAction :: action -> HaloM props state action m Unit, onFinalize :: Maybe action, onInitialize :: props -> Maybe action, onUpdate :: props -> props -> Maybe action }
22
+
type EvalSpec props state action m = { onAction :: action -> HaloM props state action m Unit, onFinalize :: Maybe action, onInitialize :: props -> Maybe action, onUpdate :: props -> props -> Maybe action }
19
23
```
20
24
25
+
A simpler interface for building the components eval function. The main lifecycle events map directly into
26
+
actions, so only the action handling logic needs to be written using `HaloM`.
27
+
21
28
#### `defaultEval`
22
29
23
30
```purescript
24
-
defaultEval :: forall props action state m. EvalSpec props action state m
31
+
defaultEval :: forall props action state m. EvalSpec props state action m
25
32
```
26
33
34
+
The empty `EvalSpec`.
35
+
27
36
#### `makeEval`
28
37
29
38
```purescript
30
-
makeEval :: forall props action state m. EvalSpec props action state m -> Lifecycle props action -> HaloM props state action m Unit
39
+
makeEval :: forall m action state props. (EvalSpec props state action m -> EvalSpec props state action m) -> Lifecycle props action -> HaloM props state action m Unit
31
40
```
32
41
42
+
Given an `EvalSpec` builder, it will return an eval function.
43
+
33
44
#### `runAff`
34
45
35
46
```purescript
36
47
runAff :: Aff Unit -> Effect Unit
37
48
```
38
49
50
+
Simple way to run Aff logic asynchronously, while bringing errors back into Effect.
0 commit comments