useObservable Hook
Since all the fundamental constructs like Units, Actions, Systems, and Clusters are Observable, it makes sense that we create a custom Hook to easily bind their value to a component's local state. useObservable
is much simpler and ergonomic to use than useUnit.
useObservable Hook:
Example:
More Examples:
StackBlitz example that shares a Unit among multiple components.
Simple Counter example.
See this for usage in combination with AsyncSystem.
Last updated