Skip to content

Instantly share code, notes, and snippets.

@iurevych
Created August 11, 2018 18:27
Show Gist options
  • Save iurevych/c8555b3bf161b79b5fa12cb1795805e9 to your computer and use it in GitHub Desktop.
Save iurevych/c8555b3bf161b79b5fa12cb1795805e9 to your computer and use it in GitHub Desktop.
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