Skip to content

Add handler_ for simple event handlers #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/React/Basic/Events.purs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ derive newtype instance categoryBuilder :: Category EventFn
handler :: forall a. EventFn SyntheticEvent a -> (a -> Eff (react :: ReactFX) Unit) -> EventHandler
handler (EventFn fn) cb = mkEffFn1 $ fn >>> cb

-- | Create an `EventHandler` which discards the `SyntheticEvent`.
-- |
-- | For example:
-- |
-- | ```purs
-- | input { onChange: handler_ (setState \_ -> { value })
-- | }
-- | ```
handler_ :: forall a. Eff (react :: ReactFX) Unit -> EventHandler
handler_ = mkEffFn1 <<< const

class Merge (rl :: RowList) fns a r | rl -> fns, rl a -> r where
mergeImpl :: RLProxy rl -> Record fns -> EventFn a (Record r)

Expand Down