Created
August 11, 2018 18:27
-
-
Save iurevych/c8555b3bf161b79b5fa12cb1795805e9 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
export const SomeStore = types | |
.model('SomeStore', { | |
settings: types.optional(Settings, {}), | |
key1: '', | |
key2: false, | |
}) | |
.actions(self => ({ | |
load: () => { | |
makeYourAjaxCall().then(response => self.update(response.data)) | |
}, | |
update: data => { | |
Object.keys(data).forEach(key => { | |
if (self.hasOwnProperty(key)) self[key] = data[key] | |
}) | |
}, | |
})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment