-
Notifications
You must be signed in to change notification settings - Fork 780
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
Update actions.md #1065
Update actions.md #1065
Conversation
added a section for custom payloads that also include the event. I used code from an issue solution buried in the repository.
Isn't this just a pattern, though? Maybe it doesn't belong to the documentation. |
While this pattern looks handy it does feel like it belongs in userland. Also, the PR mentions usage of |
@icylace , you’re right I should have showed how to use the event object in the code. However there is a use case for providing an argument to the action. Is this in the docs anywhere?
Is there any other way to accomplish this specific payload? I’m not sure I could have figured out this logic on my own without finding @jorgebucaran ‘s code in one of the discussions, which I basically copied here. In this use-case the argument is a function that returns a 2-tuple (a unique part of hyperapp actions). This is more that just currying, right?
Something is going on beyond my current understanding (sorry this is my own ignorance 😆) |
I agree with @Seanmcdon that this use case of creating a payload from combined event-data and static/state data is important and not immediately obvious how to do. It would be good to have a brief example in the docs. And it would make sense to have it in, or immediately following the "wrapped actions" section. Some might recall there used to be a feature known as "payload filters" which was for precisely this use case. But we removed the feature because we realized it was redundant as it can be achieved through return an action-payload tuple (exactly as @Seanmcdon explains) That said, I'm at odds with the example in this PR. I feel that introducing the I would rather have an example where the method for dispatching an action with a payload that is a combination of event and static data, was demonstrated inline in a view. Clearly, without any indirection. Perhaps something like: const InputField = (state, {name, value}) => ({
...state,
fields: {
...state.fields,
[name]: value
}
})
//...
h("input", {
type: "text",
oninput: (state, event) => [
InputField,
{ name: "hobbies", value: event.target.value }
]
}) I don't think we need to introduce any |
Yes, I agree @zaceno. This is a straightforward example without any extra fluff. I will close this and re-think about how to place it in the docs. |
added a section for custom payloads that also include the event.
I used code from an issue solution buried in the repository.