-
Notifications
You must be signed in to change notification settings - Fork 2
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
Make ReactElement a proper Monoid and other ergonomic tweaks #84
Conversation
getField :: ∀ @a. CanReceiveFromJavaScript a => String -> ReactComponentInstance -> Effect (Maybe a) | ||
getField field object = runEffectFn2 getField_ field object <#> readForeign @a | ||
foreign import getField_ :: EffectFn2 String ReactComponentInstance Foreign | ||
|
||
setField :: ∀ @a. CanPassToJavaScript a => String -> a -> ReactComponentInstance -> Effect Unit | ||
setField = runEffectFn3 setField_ | ||
foreign import setField_ :: ∀ a. EffectFn3 String a ReactComponentInstance Unit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This moved to a separate module Elmish.React.Internal
unmountedField = "__unmounted" | ||
getUnmounted = getField @Boolean unmountedField >>> map (fromMaybe false) | ||
setUnmounted = setField @Boolean unmountedField | ||
unmountedField = Field @"__unmounted" @Boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Field
value binds together field name and type, making mistakes less likely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM — nice 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet!
Now Utils.HTML.join
can just be replaced with Data.Foldable.intercalate
👍🏻
Yep. And |
ReactElement
is now a fullMonoid
.readForeign
and nested nullables where on error the expected type was reported incorrectly.