listen
method
Description
listen
is used to quickly monitor the value of the path corresponding to the current pipe node
Usage
listen(store, [path], (value) => {})
Arguments
store(Object/Array): parent store path(String/Array): path that needs to be get value callback(value(*)): listener callback function passes changed value
Returned value
(*): returns the current pipe
Examples
import iFlow,{ listen } from 'iflow'
const pipe = iFlow({
counter: 0,
foo: {
bar: 88
},
}).listen('counter', (counter) => {
console.log(counter) // log: 1
})
const store = pipe.create()
store.counter = 1
listen(store, ['foo', 'bar'], (foobar) => {
console.log(foobar) // value: 99
})
store.foo.bar = 99