Last active
May 29, 2019 20:53
-
-
Save bradfordlemley/477642902d705f924d066bd686382c8b to your computer and use it in GitHub Desktop.
Stated Library base implementation
This file contains hidden or 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
export default function createBase(initialState){ | |
let state = initialState; | |
let state$ = new Observable(); | |
function setState(newState) { | |
state = newState; | |
state$.next(state); | |
} | |
function updateState(update) { | |
setState({ | |
...state, | |
...update, | |
}); | |
} | |
return { | |
get state() {return state}, | |
state$, | |
setState, | |
updateState, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment