Extensions overview
Overview
Extensions allow to extend functionality of Hookstate. An extension can:
- provide state lifecycle callbacks and maintain its own state associated with the Hookstate State
- add extension methods and properties to the Hookstate State object returned by
hookstate
anduseHookstate
functions - work identically on a global and local states
- be combined together with other extensions via
extend
function and multiple extension can be added to the same state (Demo) - use the functionality provided by other extensions
Please, submit pull request if you would like your extensions included in the list.
Standard extensions
Extension | Description | Example | Package | Version |
---|---|---|---|---|
Clonable | Defines state cloning capabilities. | In Snapshotable demo | @hookstate/clonable | |
Comparable | Defines state comparison capabilities. | In Snapshotable demo | @hookstate/comparable | |
Serializable | Adds serialization and deserialization capabilities to a state. | In Snapshotable demo | @hookstate/serializable | |
Identifiable | Enable state labeling and identification by string identifier. | In Snapshotable demo | @hookstate/identifiable | |
Initializable | Provides a way to run one off initialization callback after a state is created. | In Snapshotable demo | @hookstate/initializable | |
Subscribable | Make it easier to subscribe a custom callback to state changes. | Demo | @hookstate/subscribable | |
Snapshotable | Enables access to an initial value of a State and allows to check if the current value of the state is modified (compares with the initial value). Helps with tracking of modified form field(s). | Demo | @hookstate/snapshotable | |
Validation | Enables validation and error / warning messages for a state. Useful for validation of form fields and form states. | Demo | @hookstate/validation | |
Localstored | Enables persistence of managed states to browser's local storage. | Demo | @hookstate/localstored | |
Broadcasted | Enables synchronization of a state across browser tabs. | Demo | @hookstate/broadcasted |
Development tools
Extension | Description | Example | Package | Version |
---|---|---|---|---|
DevTools | Development tools for Hookstate. Install Chrome browser's extension and activate the extension in your app. Learn more about using the development tools. | Demo | @hookstate/devtools | |
Logged | Enables logging into the development console (or elsewhere if specified) when state is created, updated and destroyed. | @hookstate/logged |