Last active
December 17, 2017 01:55
-
-
Save chenglou/e43f9a3c3ea924cbcf6e57f87d244f0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reducer: { | |
| Edit => (state) => ReasonReact.Update({...state, editText: todo.title}) | |
| Submit => submitHelper | |
| Change(text) => | |
(state) => | |
editing ? | |
ReasonReact.Update({...state, editText: text}) : | |
ReasonReact.NoUpdate | |
| KeyDown(27) => | |
/* escape key */ | |
onCancel(); | |
(state) => ReasonReact.Update({...state, editText: todo.title}) | |
| KeyDown(13) => | |
/* enter key */ | |
submitHelper | |
| KeyDown(_) => state => ReasonReact.NoUpdate | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* swap ordering */ | |
| KeyDown(_) => ReasonReact.NoUpdate | |
| Change(text) => editing ? ReasonReact.Update(state => {...state, editText: text}) : ReasonReact.NoUpdate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One downside: It's a lot more typing out of lambdas. I think it would increase the demand for a lighter weight way to register event handlers like:
Just to avoid lambda fatigue.
There's ways to do that but it's a fairly invasive change.