Last active
September 26, 2019 16:28
-
-
Save Palatnyi/1612c88c7205369cadf1cff21b2e22a6 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
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