Skip to content

Refactor events #144

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 4 commits into from
Apr 18, 2018
Merged

Refactor events #144

merged 4 commits into from
Apr 18, 2018

Conversation

ethul
Copy link
Contributor

@ethul ethul commented Apr 15, 2018

@natefaubion - Changes we discussed earlier in #140 (comment)

, preventDefault :: Eff eff Unit
, isDefaultPrevented :: Eff eff Boolean
, stopPropagation :: Eff eff Unit
, isPropagationStopped :: Eff eff Boolean
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to add these as rows in the event? All SyntheticEvents support these methods, and if they weren't in the row then we wouldn't need to propagate the eff variable.

@ethul
Copy link
Contributor Author

ethul commented Apr 15, 2018 via email

@ethul
Copy link
Contributor Author

ethul commented Apr 15, 2018

I've removed the eff functions from SyntheticEvent. Thanks for taking a look at this.

Does this seem good to go? If so, I will make a release a new release of the library. Unless there is anything else we should add in to the breaking changes.

type SyntheticEvent = Record (SyntheticEvent' ())
import Data.Symbol (class IsSymbol, SProxy(..), reflectSymbol)

type SyntheticEvent r
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these rows be closed? For example, it's not possible to have both a mouse event and an animation event.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. These can be closed. Good catch.

animationName :: forall eff r. SyntheticEvent_ (SyntheticAnimationEvent' r) -> Eff eff String
animationName = get (SProxy :: SProxy "animationName")

clipboardData :: forall eff r. SyntheticEvent_ (SyntheticClipboardEvent' r) -> Eff eff NativeDataTransfer
Copy link
Contributor

Choose a reason for hiding this comment

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

Additionally, I think that accessors could be polymorphic.

clipboardData :: forall eff r. SyntheticEvent_ (clipboardData :: NativeDataTransfer | r) -> Eff eff NativeDataTransfer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks good.

=> SProxy l
-> SyntheticEvent_ s
-> Eff eff a
get l r = unsafeGet (reflectSymbol l) r
Copy link
Contributor

Choose a reason for hiding this comment

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

This carries a fully polymorphic effect variable. Should it have a label?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you suggesting we added in something Eff (sythenticEvent :: SYNTHETIC_EVENT) a? That works for me.

Copy link
Contributor

Choose a reason for hiding this comment

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

Possibly. Seems like overkill to have another label for react stuff, but I'm not sure what the solution is short of consolidating the other labels we have. With 0.12 Effect transition coming up I wonder if it even matters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am leaning toward not adding an effect label, unless we decide it is necessary. Agreed that with the 0.12 changes, it may not be worthwhile adding here. But I am open to ideas.

@ethul
Copy link
Contributor Author

ethul commented Apr 17, 2018

@natefaubion Do you think this is good to go? Also, any further thoughts on adding-in the label for Eff?

@natefaubion
Copy link
Contributor

I think it's fine to omit the label for now.

@ethul
Copy link
Contributor Author

ethul commented Apr 18, 2018

Sounds good. Thanks.

@ethul ethul merged commit bd3933d into master Apr 18, 2018
@ethul ethul deleted the events branch April 18, 2018 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants