Skip to content

Instantly share code, notes, and snippets.

@Palatnyi
Last active September 26, 2019 16:28
Show Gist options
  • Save Palatnyi/1612c88c7205369cadf1cff21b2e22a6 to your computer and use it in GitHub Desktop.
Save Palatnyi/1612c88c7205369cadf1cff21b2e22a6 to your computer and use it in GitHub Desktop.
class User {
constructor(getState, rootUpdater) {
this._getState = getState;
this._rootUpdater = rootUpdater;
this.name = '';
this.surname = '';
}
_setValue = (value = {}) => {
this._rootUpdater({
user: {
setName: this.setName,
setSurname: this.setSurname,
...this._getState().user,
...value
}
});
};
setName = (name = '') => {
this._setValue({name});
}
setSurname = (surname = '') => {
this._setValue({surname});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment