Open milesfrain opened 4 years ago
Thanks for pointing this out, @milesfrain. I think there are two things we can do for now, and maybe we can do even more in the future to make this clear.
First, it's a decent approximation to replace any use of Action
in Halogen with HookM m Unit
in Hooks. In some cases it's not even an approximation, it's the actual case: for example, the HTML type used in Hooks is the same one as that used in Halogen, except that it uses HookM m Unit
as the action type. So if you read in the documentation for emit
that it "emits an action via the emitter", then in Hooks that means you would emit a HookM m Unit
via the emitter.
Second, I'm happy to add an example to this repository that uses subscriptions and event sources, as there is no existing example. Ideally it would be something smaller than the Ace example (perhaps a timer or something like that) just to avoid needing to keep up to date with a third-party component.
I'm open to other suggestions for how to make this "action" distinction more clear as well.
Just FYI. TimeHalogen
in the cookbook is using the affEventSource
, so there's already an example for that.
I've added labels for this as it's something that could be added to the project documentation (even if just by copy/pasting my description into the docs somewhere).
is this issue still relevant now that this functionality got moved into halogen-subscriptions
?
A fix is possible in the main Halogen code, but the issue only affects Hooks users, so I wouldn't consider it a regular Halogen issue.
The help docs for
emit
are a bit too specific, wherea
is assumed to be an "action".myEventSource = EventSource.affEventSource \emitter -> do Aff.delay (Milliseconds 1000.0) EventSource.emit emitter (Notify "hello") pure mempty