A hooks library for halogen.
The library is comprised of three modules:
Halogen.IHooks
: core hooks library.Halogen.IHooks.Sugar
: one-liners for stuff that I found myself writing over and over.Halogen.IHooks.Compat
: a "drop-in" library forpurescript-halogen-hooks
. The types are different, but the syntax should be identical.
myComponent = Hooks.component Hooks.defaultOptions \input -> Ix.do
count <- Sugar.hookConsPure (Proxy :: _ "count") 0
ipure $
HH.button
[ HE.onClick \_ -> Sugar.modify_ (Proxy :: _ "count") (_ + 1) ]
[ HH.text $ show count ]
The main difference with purescript-halogen-hooks
is that the index of the hook is a Symbol
proxy determined by the calling code.
This allows you to inspect the type in the IDE as you're putting together the hooks.
Check out the example code, and play with it live on purescript-halogen-ihooks.surge.sh.
Contributions are welcome! If you feel anything could be improved or needs more clarity, please don't hesitate to open an issue or make a pull request.
- Type-safety
- Small core API (less than 300 lines of code)
- Helpful error messages
- Semantic naming of hooks via symbols
- Performance