4 ms·
Heh I know exactly what you mean. Just 3 hours ago I was thinking about rewriting it, but 4 actions and 4 stores don't justify it. Thanks for sharing. For the
by lukasm 11y ago
Heh I know exactly what you mean. Just 3 hours ago I was thinking about rewriting it, but 4 actions and 4 stores don't justify it. Thanks for sharing.
For the reader. This starts to grow quite quickly.
import SearchActions from './actions/searchActions.js';
import VideoActions from './actions/videoActions.js';
import VideoMetaActions from './actions/videoMetaActions.js';
import MusicPlayerActions from './actions/musicPlayerActions.js';
import SearchStore from './stores/searchStore.js';
import VideoStore from './stores/videoStore.js';
import VideoMetaStore from './stores/videoMetaStore.js';
import MusicPlayerStore from './stores/musicPlayerStore.js';
class Flux extends Flummox {
constructor() {
super();
this.createActions('search', SearchActions);
this.createStore('search', SearchStore, this);
this.createActions('video', VideoActions);
this.createStore('video', VideoStore, this);
this.createActions('videoMeta', VideoMetaActions);
this.createStore('videoMeta', VideoMetaStore, this);
this.createActions('musicPlayer', MusicPlayerActions);
this.createStore('musicPlayer', MusicPlayerStore, this);
}
}
What is more, store registration could be improved as well
const videoMetaActions = flux.getActions('videoMeta');
this.register(videoMetaActions.setAudioVolume, this.handleAudioVolume);
this.register(videoMetaActions.setMusicVolume, this.handleMusicVolume);
this.register(videoMetaActions.setMusicUrl, this.handleMusicUrl);