tn-reactive
v7.3.0
Published
Downloads
10
Readme
new Reactive()
Class that creates a reactive state.
const state = new Reactive(value)
state.current = 1
console.log(state.current)
const handle = state.on(value => console.log(value))
handle.disconnect()
| Properties | Info |
| ---------------- | ----------------------------------------- |
| .id
| ReactiveState()
instance id |
| .current
| Current state of ReactiveState()
|
| .version
| Current state version |
| .set(value)
| Same as setting value to .current
|
| .emit(value)
| Best fits when using useReactiveEvent()
|
| .forceUpdate()
| Force callback to all listeners |
| .on(func)
| Start listening to any update |
useReactive()
& useReacnull()
const state = new Reactive(value)
const value = useReactive(state)
const nullable: null | Reactive<T> = null
const value = useReacnull(nullable)
useReactiveState()
& useReacnullState()
const state = new Reactive(value)
const [value, setValue] = useReactiveState(state)
const nullable: null | Reactive<T> = null
const [value, setValue] = useReacnullState(nullable)
useReactiveEvent()
& useReacnullEvent()
const state = new Reactive(value)
useReactiveEvent(state, newval => { ... }, [deps])
const nullable: null | Reactive<T> = null
useReacnullEvent(nullable, newval => { ... }, [deps])
useReactiveUpdate()
& useReacnullUpdate()
const state = new Reactive(value)
useReactiveUpdate(state)
const nullable: null | Reactive<T> = null
useReacnullUpdate(nullable)