@whitetrefoil/unistore-act
v0.2.0
Published
Act a action directly from DOM events for unistore.
Downloads
4
Readme
@whitetrefoil/unistore-act
WARNING: THIS APPLICATION IS STILL DEVELOPING!!!
Act a action directly from DOM events for unistore.
Why This?
Usually we call an action like: myAction(payload)
.
While the payload
often is ev.target.value
.
So here is a shortcut.
Usage
act(myAction)
// equals
(ev: Event) => myAction(ev.target.value)
// Here's also a `currentTarget` version:
cact(myAction)
// equals
(ev: Event) => myAction(ev.currentTarget.value)
import { act } from '@whitetrefoil/unistore-act'
const myAction = // some action
class MyComp {
// ...
render() {
return (
<div><button onClick={act(myAction)}>Click Me!</button></div>
)
}
// ...
}
Changelog
v0.2.0
- Change API in order to be compatible with
@whitetrefoil/[email protected]
.
v0.1.0
- Initial release.