Last active
November 14, 2019 23:45
-
-
Save sarimarton/b1df35a4c228f3ea6b3a92d71f40d1ae to your computer and use it in GitHub Desktop.
Auto-save SM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Auto-save SM | |
Idle* | |
change -> Save | |
Save | |
save -> s1d1 | |
s1d1 | |
response -> s0d1 | |
change -> dirty-s1d1 | |
debounceover -> s1d0 | |
s1d0 | |
response -> Idle | |
change -> dirty-s1d1 | |
s0d1 | |
change -> dirty-s0d1 | |
debounceover -> Idle | |
dirty-s1d1 | |
response -> dirty-s0d1 | |
change -> dirty-s1d1 | |
debounceover -> dirty-s1d0 | |
dirty-s1d0 | |
response -> Save | |
change -> dirty-s1d1 | |
dirty-s0d1 | |
change -> dirty-s0d1 | |
debounceover -> Save |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let debounceId | |
let revId = 0 | |
function render(model){ | |
let activeState = model.active_states[0].name | |
if (activeState === 'Save') { | |
revId += 1 | |
setTimeout(() => { model.emit('response') }, 200) | |
model.emit('save') | |
} | |
if (/d1/.test(activeState)) { | |
clearTimeout(debounceId) | |
debounceId = setTimeout(() => model.emit('debounceover'), 500) | |
} | |
return (<> | |
Rev: {revId}<br />{activeState}<br /> | |
<textArea onChange={() => model.emit('change')}></textArea> | |
</>) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment