3 ms·
That is an arrow function. children() is supposed to take a function as argument and that function is supposed to return the list of children. So basically:
by emilsedgh 10y ago
That is an arrow function.
children() is supposed to take a function as argument and that function is supposed to return the list of children.
So basically:
children( function(el) {
return [
el.email = input(props({ type: 'email' })),
el.pass = input(props({ type: 'pass' })),
el.submit = button(text('Sign in'))
]
} )
Also,
[
el.email = input(props({ type: 'email' }))
,
...
]
is a neat idea. In one (expressive) line he is assigning the value to the array and also giving the child (in this case, email) a name and reference in its parent, so later he can just call el.email (in the onsubmit function).
- akst 10y agoAt first I was gonna say, this could be expressed with an object expression, but actually if you think about it object expressions don't grantee ordering of it's elements, that and you could probably don't need a reference to all children of a component.
- pkstn 10y agoYeah, I'm using similar technique with FRZR as well (https://frzr.js.org https://frzr.js.org), but with RE:DOM I wanted to experiment with ES2015 and also break the API to smaller parts, which you can replace with your own if you like..