Skip to content

Permit effects in middleware staging #13

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

Open
natefaubion opened this issue Jan 2, 2018 · 1 comment
Open

Permit effects in middleware staging #13

natefaubion opened this issue Jan 2, 2018 · 1 comment

Comments

@natefaubion
Copy link

I'd like to request changing the type of Middleware from:

newtype Middleware eff state action a b =
  Middleware (MiddlewareAPI eff state action -> Dispatch eff action a -> Dispatch eff action b)

To something like

newtype Middleware eff state action a b =
  Middleware (MiddlewareAPI eff state action -> Eff eff (Dispatch eff action a -> Dispatch eff action b))

Note the intermediate Eff. This is important for doing staged initialization of middlewares. That is, the middleware relies on having the MiddlewareAPI before it can be initialized. In JS, the effects are pervasive so this would just be implicit and expected, and is how Redux internally initializes them. Otherwise in JS, there'd be no use for currying it.

I think technically it should be something like:

newtype Middleware eff state action a b =
  Middleware (MiddlewareAPI eff state action -> Eff eff (Dispatch eff action a -> Eff eff (Dispatch eff action b)))

But I haven't come across a use for the second Eff wrapping.

@ethul
Copy link
Owner

ethul commented Jan 2, 2018

I like your proposal. Makes sense. If you are interested in opening up a PR for this change, it would definitely be welcome. I can also make the update if you prefer. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants