Open plandem opened 7 years ago
I'm not 100% sure what you're going for, but the idea of RRC was to prevent the need for async middleware.
Is the issue that you're trying to essentially apply a decorator (blocking
) to a controller method, but that decorator needs a reference to dispatch
, but you can only get a handle to it in initialize
? Would it also be possible to make blocking
a controller generator method?
in two words, I need to decrease the number of boilerplate code for next behavior:
p.s.: yes, some kind of decorator, that dispatches an action at start and before end of action.
Required: somehow inside of controller without a lot of boilerplate code to get next: at begin of method dispatch action with promise for promise-middleware, that will be resolved/rejected at the end of method.
Recap: 1) at begin of method set some redux state to true 2) at end of method set same redux state to false 3) at error do same as at (2)
In most cases it's common loading flag (e.g. API requests) to make UI to response changes of state (e.g. block/unblock controls).
Right now I'm doing it like this, but not sure that it's good way, maybe I miss something:
helper:
generators with marked onLogin as blocking:
I need it for my reducer, e.g.:
utils is like this: