Introducing PureScript Halogen Helix

Dear all!

I would like to introduce my recent work: Halogen Helix, a lightweight global state management library for Halogen app.

At the time of writing, there already exists a great library sharing the same purpose: halogen-store, so what is the point of adding one?
Indeed Helix shares the fundamental concepts with halogen-store, but to be sure, it differs in several points:

  • Helix is hook-first
    The Helix store can be accessed only in hook-style components. It is not impossible to connect non-hook style component to the Helix store, but to do that, you need to do some low level stuff.

  • Simple interface
    With halogen-store’s useSelector, it is also possible to access the store inside hook-style components, but the state value returned by the useSelector hook is always wrapped in Maybe context. With Helix providing functionality, the state value does not have additional Maybe.

  • More granular structuring of State type
    With halogen-store, you define a single, sometimes large, store; with Helix, you can create as many stores as you need, leading more finely structured store definition.

For more information, please refer to the README. I hope you feel like to trying it out.
Any feedback would be appreciated!

12 Likes

:tada: I’m happy to announce the v1.0.0 release of halogen-helix :tada:

Now you can install it with Spago, and read the API docs in the pursuit documentation site.

Since I have posted the reply-to, I have made some changes to the library:

  • simplified internal state manipulation logic
  • added middleware API, the way to extend the store behavior with almost arbitrary effectful logic
  • added some automated tests, unit and E2E
6 Likes

Hey,

Great library! I’m just starting out in Purescript but I found the api familiar enough coming from redux and react hooks.

I did notice one weird issue where my UseHelixHook state was sometimes undefined. I figured I could just check to make sure the value is defined but the type system does not recognize an undefined state.

I haven’t had a change to right an issue yet with an example repo, so I thought I’d mention here.

1 Like

Thank you for using Helix!

Hmm…It certainly seems that something is going wrong. I’m sorry for bothering you.

I will take a look and fix the bug as soon as possible, but as long as I read the description you wrote in the post, I have no clue what’s going on. So though I’ll do my best, it may take a moment to fix :persevere: