meteorflux icon indicating copy to clipboard operation
meteorflux copied to clipboard

more flexible implementation of filters

Open repomaa opened this issue 8 years ago • 3 comments

this is merely a suggestion on how to handle filters. I'm open to any input you may have on this. My implementation is inspired by redux. Filters would be defined like this:

Dispatcher.addDispatchFilter(dispatch => {
  return (payload, next) => {
    // do something
    next(payload);
  }
});

if next isn't called, the filter chain will not continue. At the end of the chain is the actual dispatch function which receives the resulting payload. It is also possible to interrupt the chain (by not calling next) and dispatching prematurely with the dispatch function passed to the filter. This is nice for handling errors for example or adding a logger.

I also included both of the _curate functions to the normal dispatch/register flow. This reduces the usage of arguments and is clearer imho.

What do you think?

repomaa avatar Nov 27 '15 18:11 repomaa