v0.2.0
This release fixes several bugs and changes some types used in the Halogen Hooks library.
Breaking changes (😱!!!):
Introduce tokens for all component-only features, not just queries (#22)
Hooks support writing functions for stateful logic, which are then interpreted by a Halogen component. However, some component features do not make sense in the context of Hooks alone (queries, slot types, and output messages).
The first version of Hooks made queries available in a Hook only via a query 'token', which was provided by the componentWithQuery
function. This approach has been extended to slot types and output messages as well. With this change Hook types no longer carry around slot or output types, which cleans up type signatures for the vast majority of cases, but they are still able to support child components and sending messages once used with the component
function.
This includes several breaking changes, all of which are simple to adjust to the new version (no features have been removed). In summary, any Hook types that previously accepted a slot and output type will no longer have them, and any Hook functions that use these types will now use a token as their first argument. Here's the full list of changes:
Hook ps o m hooks a
is nowHook m hooks a
Hooked ps o m hooksPre hooksPost a
is nowHooked m hooksPre hooksPost a
HookM ps o m a
is nowHookM m a
- The
component
function has been updated to take as its first argument a record containing the query token, slot token, and output token that can be used to enable component features in a Hook. Any usage ofcomponent \input -> ...
can be replaced withcomponent \_ input -> ...
. - The
componentWithQuery
function has been removed, as it is now covered bycomponent
. Any usage ofcomponentWithQuery \queryToken _ -> ...
can be replaced bycomponent \{ queryToken } _ -> ...
. - The
HookM
functionraise
now takes as its first argument anOutputToken
. Any use ofHooks.raise output
can be replaced bycomponent \{ outputToken } _ -> ... Hooks.raise outputToken output
. - The
HookM
functionsquery
andqueryAll
now take as their first argument aSlotToken
. Any use ofHooks.query ...
can be replaced bycomponent \{ slotToken } _ -> ... Hooks.query slotToken ...
.
Bugfixes:
- Memo values could get out of sync with their indices in state (#11)
- Effect cleanup for useTickEffect would not run until the component finalized, running all cleanup functions together at the end (#12)
- State changes triggered by effects would not cause hooks to be re-evaluated (#20)
Other improvements:
- Tests: add automated tests for Hooks (#19)
- Tests: add continuous integration to the repository via GitHub Actions
- Docs: update the documentation to make it clear when getting state vs. using the state from
useState
is necessary (#7) - Docs: update all public documentation to use new types and remove mention of
componentWithQuery