-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
this.emit('change') vs this.emitChange() #91
Comments
I've been thinking about this quite a bit since #58, but I'm hesitant to make it part of the base store API. It's likely that an event named I've considered a method called The typo argument is valid, but I think a bit weak, as one could easily define a constant somewhere and use it for event emissions: var CHANGE = "change";
// ...
this.emit(CHANGE); I'm also fond of the idea of mixins (see #37), and while the proposed PR adds a considerable amount of complexity to Fluxxor's stores, version 2 of the Fluxxor API will have the ability to use completely custom stores if you so wish. In the meantime, if there are methods you want to use in multiple stores, you can use // store_mixin.js
module.exports = {
emitChange: function() { this.emit("change"); },
// maybe other methods here
};
// my_store.js
var assign = Object.assign || require("object-assign"),
storeMixin = require("./store_mixin");
module.exports = Fluxxor.createStore(assign({}, storeMixin, {
handleEvent: function() {
// ...
this.emitChange();
}
})); I'm going to leave this open for now to foster discussion. |
One thing that I really like about |
I mean, the On Sun, Jan 11, 2015 at 2:50 PM, David Jacobs [email protected]
|
It seems odd to have this one event not use a constant when every other emitted event should be using constants. I think that there should be this method in stores to prevent typos.
The text was updated successfully, but these errors were encountered: