Created
December 16, 2018 12:38
-
-
Save ksnabb/8122a3143279dfb10f57069c5ee3c540 to your computer and use it in GitHub Desktop.
Seconds elapsed using pubsub.js and state.js
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
const appEvents = pubSub(); | |
const appState = state(0, appEvents); | |
function timer() { | |
appState.setValue(appState.getValue() + 1); | |
setTimeout(timer, 1000); | |
} | |
setTimeout(timer, 1000); | |
function updateTimerView(val) { | |
document.querySelector(".seconds-elapsed").innerText = `seconds elapsed ${val}`; | |
} | |
appEvents.subscribe(updateTimerView); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment