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

refactor!: update to latest brisk-reconciler #576

Merged
merged 50 commits into from
Nov 11, 2019

Conversation

lessp
Copy link
Member

@lessp lessp commented Oct 1, 2019

So, pushing what I've got, I began converting the examples. Most of the should be OK now hopefully. Got a bit stuck on the UI_Primitives type-errors.

This PR introduces the changes from brisk-reconciler with the new syntax:

e.g.

let%component make = () => {
  let%hook (counter, setCount) = React.Hooks.state(0);

  <Clickable onClick={_ => setCount(prevCount => prevCount + 1)}>
    <Text style=Style.[...] text={string_of_int(counter)} />
  </Clickable>
};

@lessp
Copy link
Member Author

lessp commented Oct 3, 2019

Btw, this is a PR for merge into: #566

@@ -5,7 +5,7 @@ open Revery.UI.Components;
module DefaultButtonWithCounter = {
let%component make = () => {
let%hook (count, setCount) = Hooks.state(0);
let increment = () => setCount(count + 1);
let increment = () => setCount(_ => count + 1);
Copy link
Member

Choose a reason for hiding this comment

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

You're supposed to do setCount(count => count + 1); here. That's why it was made a function ;) It's unlikely to cause a problem if you don't, especially in this case where it worked absolutely fine before, but when it does cause a problem it's a tricky one to find because it requires breaking the abstraction. It also might be very hard to reproduce. See briskml/brisk-reconciler#26 for details.

Copy link
Member Author

@lessp lessp Oct 28, 2019

Choose a reason for hiding this comment

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

Yep! I just mangled through all these and lazily replaced them with _!

EDIT: Could probably do a search and replace for (_ => and walk through them! 🙂

@lessp
Copy link
Member Author

lessp commented Oct 28, 2019

Ok, so with a few files commented out:

This builds and runs, with the core changes happening in UI/Reconciler.re and UI/Container.re

@Et7f3
Copy link
Member

Et7f3 commented Oct 29, 2019

I don't why I have a empty windows when executing esy run

@lessp
Copy link
Member Author

lessp commented Oct 29, 2019

Merged with master, some examples doesn't run:

  • Input~

@Et7f3
Copy link
Member

Et7f3 commented Oct 29, 2019

You should better rebase onto master instead of merging (you will avoid this kind of merge error).

js.json Outdated Show resolved Hide resolved
src/UI/Container.re Outdated Show resolved Hide resolved
src/UI_Components/Button.rei Show resolved Hide resolved
src/UI_Components/Clickable.re Show resolved Hide resolved
src/UI_Components/ExpandContainer.re Show resolved Hide resolved
src/UI_Hooks/Animation.rei Outdated Show resolved Hide resolved
test/UI/ReconcilerTests.re Outdated Show resolved Hide resolved
~height=?,
~src="",
~style=Style.emptyImageStyle,
~children=React.empty,
Copy link
Member

Choose a reason for hiding this comment

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

Image can have children 👀

Copy link
Member

Choose a reason for hiding this comment

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

Same for other Primitives like OpenGL

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think this changes that, we just need t provide an empty children as a default which is needed IIRC!

Copy link
Member

Choose a reason for hiding this comment

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

Scrollview, Row, Container, Center must have one argument so default arg to React.empty is not fine for me. Ticker shouldn't have child.

Copy link
Member

Choose a reason for hiding this comment

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

I though not exposing argument and defining a local children variable. What do you think ? I can fix that.

Copy link
Member Author

Choose a reason for hiding this comment

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

That might make sense, but it differs from how master looks currently: https://github.com/revery-ui/revery/blob/master/src/UI_Components/Input.re#L356

Copy link
Member Author

Choose a reason for hiding this comment

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

I've updated all containers except Container as to explicitly take children @Et7f3.
Do you want me to push these, or do you want to create a separate issue for that?

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see so create another issue. IIRC @bryphe wanted some compile time assertion to be verified.

Copy link
Member

Choose a reason for hiding this comment

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

for reference #489 (comment)_

@lessp
Copy link
Member Author

lessp commented Nov 3, 2019

Wonder if we should change the merge target to master instead of #566?

@lessp lessp changed the title chore: convert examples and some components refactor!: update to latest brisk-reconciler Nov 3, 2019
@Et7f3
Copy link
Member

Et7f3 commented Nov 3, 2019

When reviewing it I compared this branch and master and it was clean. I think it is better to change it.

@bryphe
Copy link
Member

bryphe commented Nov 8, 2019

So cool to see this green and the let%hooks land! 🎉 Thanks for all the work / help with this!

Pretty heroic and impressive change @lessp @wokalski @Et7f3

Wonder if we should change the merge target to master instead of #566?

Sounds good to me! We can just close #566 in lieu of this more complete change 😄

Copy link
Member

@bryphe bryphe left a comment

Choose a reason for hiding this comment

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

So cool to see the let%hook and let%component PPXs in action to remove the boilerplate we have today,

@wokalski
Copy link
Collaborator

wokalski commented Nov 8, 2019

The only problem is that let%hook doesn't work in reis currently. And it's hard to make it work there.

@lessp lessp changed the base branch from component-ppx to master November 8, 2019 20:01
@lessp
Copy link
Member Author

lessp commented Nov 9, 2019

The only problem is that let%hook doesn't work in reis currently. And it's hard to make it work there.

Would you like to get this in before merging, or should we add it at a later stage? @wokalski @Et7f3

@wokalski
Copy link
Collaborator

wokalski commented Nov 9, 2019

No, it’s very hard. There are lower hanging fruits with more ROI.

@bryphe
Copy link
Member

bryphe commented Nov 11, 2019

Awesome! Let's bring this in - very exciting! 🎉 Thanks @wokalski @lessp @Et7f3

@bryphe bryphe merged commit 700ecc7 into revery-ui:master Nov 11, 2019
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.

5 participants