Skip to content

Instantly share code, notes, and snippets.

@giacomorebonato
Created July 15, 2016 08:46
Show Gist options
  • Save giacomorebonato/fe0544d9c1249cade243175e9a44c773 to your computer and use it in GitHub Desktop.
Save giacomorebonato/fe0544d9c1249cade243175e9a44c773 to your computer and use it in GitHub Desktop.
SampleStore
import { observable, action } from 'mobx'
import objectAssign = require('object-assign')
class SampleStore {
constructor (data?) {
if (data) {
this.setData(data)
} else if (window['data']) {
let wData = window['data'] as any
if (wData.sampleStore) {
this.setData(wData.sampleStore)
}
}
}
@observable
title = 'Welcome to my BP!'
@action('SET_DATA')
setData (data) {
objectAssign(this, data)
}
@action('CHANGE_TITLE')
changeTitle (title: string) {
this.title = title
}
}
export default SampleStore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment