Skip to content

Instantly share code, notes, and snippets.

@DanielZhangQingLong
Created April 27, 2018 15:54
Show Gist options
  • Save DanielZhangQingLong/866f74482d20aa7a59fa79fd59cf959b to your computer and use it in GitHub Desktop.
Save DanielZhangQingLong/866f74482d20aa7a59fa79fd59cf959b to your computer and use it in GitHub Desktop.
import EventEmitter from '../event_emitter'
// Simulate a store. In real world, this should be an API request.
const Seniors = {
"1": {
url: "http://photocdn.sohu.com/20140811/Img403316505.jpg"
},
"2": {
url: "http://photocdn.sohu.com/20140811/Img403316505.jpg"
}
}
const SeniorStore = new EventEmitter();
SeniorStore.fetchAllSeniors = function(){
return Seniors;
}
SeniorStore.emitChange = function() {
this.emit('change');
}
SeniorStore.addChangeListener = function(listener) {
this.on('change', listener);
}
SeniorStore.plus1s = function(s) {
Seniors[Object.keys(Seniors).length + 1] = {
url: s
}
console.log('Current Senior Store', Seniors);
this.emitChange();
}
export default SeniorStore;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment