-
Notifications
You must be signed in to change notification settings - Fork 22
Effects #179
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
Conversation
src/getHandlers.js
Outdated
function format (string) { | ||
/*eslint-disable no-unused-vars*/ | ||
const [ _, action, state = 'done' ] = `${ string }`.match(/(\w*)\_\d+[\_\w]*/) || [] | ||
/*eslint-enable no-unused-vars*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, nice. Didn't realize you could do that inline. Sad that we can't make a global exception for this pattern 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack! This file should get removed. Good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beyond that though, I want to say there's a thing you can do with no-unused-vars
that ignores variables that start with _
.
I like it. I need to sit with the term |
This probably screws up a bunch of naming internals, but I almost think this would be nice: class MyPresenter extends Presenter {
setup (repo) {
repo.register(Effects, { options })
}
} Just an idea. Not married to it. Just thinking that |
@greypants I hear you on the similarity. There's something there that I haven't figured out yet. I'm okay with it being a little confusing for the sake of consistency, but I agree that the documentation needs to be clearer. |
This PR adds the concept of effects to Microcosm, a way to apply side-effects in a safe way. Whenever an action moves into a new state, it asks the history object to reconcile. After reconciliation, I've added an extra step for handling side effects. This should support a few use cases:
These can be added to Presenters too, and localized to a particular fork. So side-effects can be managed more strategically than a simple register method: