Can we come up with a better name for the attrs action. "Attributes" only correctly describes what it does for the "rest"/"other" (non-event) properties that are passed to this action; the "main" purpose (I think) is for it to extract and attach event handlers.
Name ideas...
use:events={{'on:click': handleClick, style}} — a little bit odd to see non-events like style passed in, but at least the main purpose (?) — event handlers — is clearer
use:eventsAndAttrs={{'on:click': handleClick, style}} — more inclusive of what it does, but at the cost of being more verbose
Another idea would be to export a helper function (filterEventProps? extractEventProps?) that does the work of separating out events from non-events, and then you could pass those separate arrays to actions that are more aptly named and have only a single, clear responsibility. You could use it like this:
That's the approach I'm leaning towards currently, as it keeps things clear and avoids the action having multiple/mixed responsibilities. (Of course, you could always make/have that all-in-one action too: it could just be a wrapper for the extract and 2 use: calls like above, but having them separate gives people the option to use either...)
Can we come up with a better name for the
attrs
action. "Attributes" only correctly describes what it does for the "rest"/"other" (non-event) properties that are passed to this action; the "main" purpose (I think) is for it to extract and attach event handlers.Name ideas...
use:events={{'on:click': handleClick, style}}
— a little bit odd to see non-events likestyle
passed in, but at least the main purpose (?) — event handlers — is cleareruse:addEvents={{'on:click': handleClick, style}}
use:attachEvents={{'on:click': handleClick, style}}
use:eventsAndAttrs={{'on:click': handleClick, style}}
— more inclusive of what it does, but at the cost of being more verboseAnother idea would be to export a helper function (
filterEventProps
?extractEventProps
?) that does the work of separating out events from non-events, and then you could pass those separate arrays to actions that are more aptly named and have only a single, clear responsibility. You could use it like this:Actually, we might not even need a
use:attrs
... couldn't we just spread the rest props?(If you didn't need one or the other, you could omit it from the destructuring assignment:
)
That's the approach I'm leaning towards currently, as it keeps things clear and avoids the action having multiple/mixed responsibilities. (Of course, you could always make/have that all-in-one action too: it could just be a wrapper for the extract and 2
use:
calls like above, but having them separate gives people the option to use either...)What do you think?