Created
April 27, 2018 15:54
-
-
Save DanielZhangQingLong/866f74482d20aa7a59fa79fd59cf959b 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
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