Skip to content
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

Merged
merged 1 commit into from
Jul 29, 2024

Conversation

fsoikin
Copy link
Contributor

@fsoikin fsoikin commented Jul 29, 2024

  • By suggestion from @MonoidMusician, ReactElement is now a full Monoid.
  • Fixed a bug with readForeign and nested nullables where on error the expected type was reported incorrectly.
  • A bunch of small tweaks and fixes to some internals and docs.
  • See release notes in CHANGELOG

@fsoikin fsoikin requested review from gasi and mcordova47 July 29, 2024 03:55
Comment on lines -115 to -121
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
Copy link
Contributor Author

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
Copy link
Contributor Author

@fsoikin fsoikin Jul 29, 2024

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.

Copy link
Contributor

@gasi gasi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — nice 👍

Copy link
Contributor

@mcordova47 mcordova47 left a 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 👍🏻

@fsoikin
Copy link
Contributor Author

fsoikin commented Jul 29, 2024

Yep. And maybeHtml' is just fold

@fsoikin fsoikin merged commit 51d08ce into master Jul 29, 2024
4 checks passed
@fsoikin fsoikin deleted the tweaks branch July 29, 2024 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants