-
Notifications
You must be signed in to change notification settings - Fork 6
Question: dispatch signature #5
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
Comments
When I started working on this, I was experimenting a bit and giving some flexibility in the types since I wasn't precisely sure how I would ultimately end up using this representation. I agree that |
OK, but how about the fact it's not merely an |
Let's discuss with example: render dispatch this = do
props <- React.getProps this
pure $ loginView { onClick: \({ mail, password }) -> do
log "test"
void $ dispatch $ pure $ Login $ Login.AttemptLogin $ LoginData { username: mail, password }
, enabled: not props.inProgress && isNothing props.authData } Here, Eff
( "props" :: ReactProps
, "refs" :: ReactRefs (() :: # Effect)
, "state" :: ReactState
( "read" :: Read
)
, "console" :: CONSOLE
, "props" :: ReactProps
, "refs" :: ReactRefs
( "read" :: Read
)
, "state" :: ReactState
( "read" :: Read
, "write" :: Write
)
| t0
) Now, the type of the render is: type Render props state eff f action = (f action -> f action) -> React.Render props state eff this means, our dispatch now works within the Therefore, I think the signature Alternatively, I guess it would be // EDIT: hmm, maybe current signature makes it more convenient should one employ action creators - it would mean they could be effectful too... |
Thanks for the example. I don't really have a strong argument for Maybe adding a function On the note of returning the action from the dispatch call, I just followed what redux does in this case. Again, I don't have a strong argument for this either way. |
I suppose I'm gonna leave it as it's now and just wait to gather more use cases. |
I think I'd like to reopen this. I want to explore an idea for how to better utilize the I will post my thoughts here once I work them out a bit more. |
Hi,
I'm having troubles figuring out why exactly the type of dispatch is polymorphic over
f
:f action -> f action
. Does it has anything with middleware? If so, how could I put it to greater use? Async actions?Currently in my code I've got couple of invocations like
void $ dispatch $ pure $ Login $ Login.AttemptLogin $ LoginData { username: mail, password }
andf
is mostly inferred to be(redux :: REDUX | eff)
for all eff.The text was updated successfully, but these errors were encountered: