You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 9, 2019. It is now read-only.
Talking with @developerdizzle. We talked about middlewares and the general ideas. Here are some thoughts as a take away.
Middleware might be needed
Legimiate cases for middleware are:
history (undo/redo)
logging
Devtools
I think there are 2 ways we could approach this. actionExtender's or generic middleware.
This is how I would expect them to be implemented:
actionExtender
// happens at some top levelconsthistory=[];actionExtender('undoable',function(prevState,proposedState,componentName,actionName){// do something with the previous or proposed statehistory.push(prevState);});
functionfoo({actions}){return<inputonClick={actions.handleClick.undoable}/>// undoable being the key here}wrap(foo,{actions: {handleClick(state,next){// does somethingnext({foo: 'bar'});}}});
Pro's here are actions can opt into using a middleware. This technically isn't middleware but it might support all the use-cases we need.
middleware
This is true middleware, every action called also calls the middleware's.
// some top level filemiddleware(functionlogger(prevState,proposedState,componentName,actionName){fetch('api/v2/log',{prevState, proposedState, componentName, actionName});});
Other notes
The implementation of this should probably live on Provider. Something like this:
I think I like the actionExtender method better, specifically for undo/redo. I can see a case where you wouldn't want undo/redo to apply to every action, and I feel like it would be harder to code a middleware to selectively undo certain actions. Logging and devtools are a little more passive, so middleware makes more sense to me for those.
I've taken an initial stab at this in this branch MiddlewareAttempt1. Can't say I love it. It's hard to think of what is actually beneficial with these things in coflux. Redux did this to act in between reducers and updaters.
not sure we have an equivalent here.. needs more thought
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Talking with @developerdizzle. We talked about middlewares and the general ideas. Here are some thoughts as a take away.
Middleware might be needed
Legimiate cases for middleware are:
I think there are 2 ways we could approach this. actionExtender's or generic middleware.
This is how I would expect them to be implemented:
actionExtender
Pro's here are actions can opt into using a middleware. This technically isn't middleware but it might support all the use-cases we need.
middleware
This is true middleware, every action called also calls the middleware's.
Other notes
The implementation of this should probably live on
Provider
. Something like this:The text was updated successfully, but these errors were encountered: