This example shows UX.JS reactivity in short:
- UX.js uses a reactivity and state-management model similar to that of Vue.js and React.js.
- By default UX.js calls three functions automatically: init(), render() and effect(). All other functions need to be subscribed to, by adding them into the app.functions array.
- It is possible to call all UX.js one-way attribute bindings inside a module, making UX.js much more versatile.
- app.state is the global state and can be array, object, number or string.
UX.JS reactive methods:
- {app}.loadModule(module) - runs a module and executes it.
- {app}.loadFunction(elementId=root,function) - runs a function and injects the response into a given ID.
- {app}.functions = [function, function] - subscribes new functions which can be called through data-actions.
- {app}.state.{string} - getting/setting of a state
- {app}.initState(object,session) - initializing an object before rendering. When session is true, sessionStorage is used, default is false.
- {app}.setState(object,module.id,session) - setting and updating of a state. When session is true, sessionStorage is used, default is false.
- {app}.getState(string) - getting a state of a variable, whether in sessionStorage or in memory.
- {app}.setFun(function) - initializing a function
- {app}.releaseState() - clears sessionStorage