alt
alt copied to clipboard
alt.generateActions should also accept objects or arrays
alt.generateActions('foo', 'bar', { baz() { } })
or
alt.generateActions('foo', 'bar', ['baz', () => {}])
the first one seems to have more sense.
i always get stuck for having many syntactic choices. not sure if it's a good idea; but I find it shorter than this (because classes are verbose):
class FooActions {
constructor() {
this.generateActions('foo', 'bar');
}
baz() {
}
}
The first makes more sense to me as well, but will we have issues with the action name on minification?
Right you'd have to tell the minifier to not minify it, plus there's the risk of conflicting keys.
Is there any implementation on this? That would be very useful, I have to create the verbose 'class' syntax just for one action (all others go through generateActions).
what I do:
const dispatch = x => x
const FooActions = alt.createActions({
foo: dispatch,
bar: dispatch,
baz: dispatch,
})
You can further reduce this if you want to something else that's easily implementable in userland.