Skip to content

v0.2.0

Compare
Choose a tag to compare
@thomashoneyman thomashoneyman released this 30 Apr 21:44

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 now Hook m hooks a
  • Hooked ps o m hooksPre hooksPost a is now Hooked m hooksPre hooksPost a
  • HookM ps o m a is now HookM 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 of component \input -> ... can be replaced with component \_ input -> ....
  • The componentWithQuery function has been removed, as it is now covered by component. Any usage of componentWithQuery \queryToken _ -> ... can be replaced by component \{ queryToken } _ -> ....
  • The HookM function raise now takes as its first argument an OutputToken. Any use of Hooks.raise output can be replaced by component \{ outputToken } _ -> ... Hooks.raise outputToken output.
  • The HookM functions query and queryAll now take as their first argument a SlotToken. Any use of Hooks.query ... can be replaced by component \{ 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