Created
December 1, 2016 16:24
-
-
Save MarcoWorms/80a622b72122ddd04af1bb3fc18abc70 to your computer and use it in GitHub Desktop.
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
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