Created
July 15, 2016 08:46
-
-
Save giacomorebonato/fe0544d9c1249cade243175e9a44c773 to your computer and use it in GitHub Desktop.
SampleStore
This file contains hidden or 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
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