Currently the tutorial on the website references payload filters.
This was _experimental_ functionality and will be removed in the future (v2).
Ref: https://github.com/jorgebucaran/hyperapp/blob/minimizations/docs/tutorial.md#payloadfilters
@dwknippers what's the proper alternative in this scenario?
@zaiste The trick is that an action can return an action too (=> [MyAction, newPayload]), so I usually define a function to help me with that.
const withPayload = (filter) => (_, x) => filter(x)
and use it like this for example:
{
oninput: withPayload((event) => [
MyAction,
{ id: state.currentId, value: event.target.value },
]),
}
The action that carries the payload is the anonymous function in the middle (_, x) of withPayload.
We could (and probably should) export that from @hyperapp/events, as I also want to include higher level event utilities. e.g:
const targetValue = (action) =>
withPayload(({ target: { value } }) => [action, value])
This has been adressed in #994 We can close here I think
Most helpful comment
@zaiste The trick is that an action can return an action too (
=> [MyAction, newPayload]), so I usually define a function to help me with that.and use it like this for example:
The action that carries the payload is the anonymous function in the middle
(_, x)ofwithPayload.We could (and probably should) export that from @hyperapp/events, as I also want to include higher level event utilities. e.g: