Skip to content

Instantly share code, notes, and snippets.

@MarcoWorms
Created December 1, 2016 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarcoWorms/80a622b72122ddd04af1bb3fc18abc70 to your computer and use it in GitHub Desktop.
Save MarcoWorms/80a622b72122ddd04af1bb3fc18abc70 to your computer and use it in GitHub Desktop.
function renderState (state) {
var html = '<p>' + state.something + '</p>'
document.getElementById('root').innerHTML = html
}
function createStore() {
var state = {
something: "olá mundo"
}
renderState(state)
return {
getState: function () {
return state
},
setState: function (newState) {
state = newState
renderState(state)
}
}
}
var store = createStore()
window.setTimeout(function() {
store.setState({ something: "adeus mundo" })
}, 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment