3 ms·
They all boil down to the same thing. I use this one https://github.com/acdlite/flummox https://github.com/acdlite/flummox minimum boilerplate
by lukasm 11y ago
They all boil down to the same thing. I use this one https://github.com/acdlite/flummox https://github.com/acdlite/flummox minimum boilerplate
- patio11 11y agoFurther boilerplate reduction: https://gist.github.com/patio11/b472ccb2df3e1fcce78c https://gist.github.com/patio11/b472ccb2df3e1fcce78c I was going crazy with all the sit-ups to hook actions/stores together prior to this.
- lukasm 11y agoHeh 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);