Overview of Helux Base API functions
masterThe Helux base API provides a set of fundamental functions for state management, reactivity, and data flow. These functions can be categorized into several core capabilities:
State Creation
- Atoms: Use
atom(returns a tuple) oratomx(returns a dictionary) to create basic state objects. - Shared State: Use
share(returns a tuple) orsharex(returns a dictionary) to create dictionary-type atom objects. - Granular Reactivity: Use
signalfor DOM-level updates orblock/dynamicBlockfor block-level updates.
Derivation and Mutation
- Derivation (Read-only): Define derived state using
derive(single) orderiveDict(batch). For asynchronous tasks, usedefineDeriveTaskordefineDeriveFnItemto benefit from automatic dependency type inference. Trigger derivations manually withrunDeriveorrunDeriveTask. - Mutation (Writeable): Define mutable derived functions using
mutate(single) ormutateDict(batch). Trigger them manually withrunMutateorrunMutateTask.
Actions and Side Effects
- Actions: Create synchronous or asynchronous functions to modify state using
action. - Observation: Monitor data changes using
watchorwatchEffect(which runs immediately and collects dependencies on the first run). - Events: Use
emitto dispatch events andonto listen for them.
Data Synchronization
- Two-way Binding: Use
syncerfor shallow object synchronization orsyncfor deep object synchronization to assist with two-way data binding.