Skip to content

Instantly share code, notes, and snippets.

@bradfordlemley
Last active May 29, 2019 20:53
Show Gist options
  • Save bradfordlemley/477642902d705f924d066bd686382c8b to your computer and use it in GitHub Desktop.
Save bradfordlemley/477642902d705f924d066bd686382c8b to your computer and use it in GitHub Desktop.
Stated Library base implementation
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