mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 16:33:15 +01:00
23 lines
No EOL
416 B
JavaScript
23 lines
No EOL
416 B
JavaScript
|
|
export function createReactiveState(state = {}, update) {
|
|
|
|
return function (prop, value) {
|
|
if (state[prop] === value) {
|
|
return;
|
|
}
|
|
state[prop] = value;
|
|
update(state);
|
|
}
|
|
}
|
|
|
|
export function createExpensiveSetter(setter) {
|
|
let lastValue = NOT_SET;
|
|
return function set(value) {
|
|
if (value !== lastValue) {
|
|
lastValue = value;
|
|
setter(value);
|
|
}
|
|
}
|
|
}
|
|
|
|
const NOT_SET = {}; |