change(tracker): return ticker to track custom input changes
This commit is contained in:
parent
3266f46440
commit
00be3708a1
2 changed files with 25 additions and 0 deletions
|
|
@ -18,6 +18,12 @@ export default class Ticker {
|
|||
this.callbacks = []
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Callback} callback - repeated cb
|
||||
* @param {number} n - number of turn skips; ticker have a 30 ms cycle
|
||||
* @param {boolean} useSafe - using safe wrapper to check if app is active
|
||||
* @param {object} thisArg - link to <this>
|
||||
* */
|
||||
attach(callback: Callback, n = 0, useSafe = true, thisArg?: any) {
|
||||
if (thisArg) {
|
||||
callback = callback.bind(thisArg)
|
||||
|
|
|
|||
|
|
@ -153,6 +153,25 @@ export default function (app: App, opts: Partial<Options>): void {
|
|||
sendInputValue(id, node)
|
||||
}, 60)
|
||||
|
||||
app.ticker.attach(() => {
|
||||
inputValues.forEach((value, id) => {
|
||||
const node = app.nodes.getNode(id) as HTMLInputElement
|
||||
if (!node) return inputValues.delete(id)
|
||||
if (value !== node.value) {
|
||||
inputValues.set(id, node.value)
|
||||
sendInputValue(id, node)
|
||||
}
|
||||
})
|
||||
checkboxValues.forEach((checked, id) => {
|
||||
const node = app.nodes.getNode(id) as HTMLInputElement
|
||||
if (!node) return checkboxValues.delete(id)
|
||||
if (checked !== node.checked) {
|
||||
checkboxValues.set(id, node.checked)
|
||||
app.send(SetInputChecked(id, node.checked))
|
||||
}
|
||||
})
|
||||
}, 5)
|
||||
|
||||
app.nodes.attachNodeCallback(
|
||||
app.safe((node: Node): void => {
|
||||
const id = app.nodes.getID(node)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue