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

Allow to add a dependency dynamically via JS expression #6602

Merged
merged 11 commits into from
Oct 4, 2019

Conversation

denis-anisimov
Copy link
Contributor

@denis-anisimov denis-anisimov commented Oct 2, 2019

Fixes #6577


This change is Reviewable

@denis-anisimov denis-anisimov force-pushed the issues/6577-page-loadDependency branch from 11123ab to bb21053 Compare October 2, 2019 18:11
@ujoni ujoni added the +0.1.0 label Oct 2, 2019
Copy link
Contributor

@joheriks joheriks left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 5 files at r2, 3 of 5 files at r3, 6 of 6 files at r4, 1 of 1 files at r6.
Reviewable status: 4 unresolved discussions, 0 of 1 LGTMs obtained (waiting on @denis-anisimov)


flow-client/src/main/java/com/vaadin/client/DependencyLoader.java, line 72 at r6 (raw file):

            onLoad(event);
        }
    };

This object looks identical to EAGER_RESOURCE_LOAD_LISTENER and it does not seem stateful. Could a single object be used? (Methods inlineDependency and loadEagerDependency both refer to EAGER_RESOURCE_LOAD_LISTENER, and it looks to me like inlineDependency, loadEagerDependency and loadDynamicImport could be consolidated into a single method).


flow-client/src/test-gwt/java/com/vaadin/client/GwtSuite.java, line 52 at r6 (raw file):

        suite.addTestSuite(GwtExecuteJavaScriptElementUtilsTest.class);
        suite.addTestSuite(GwtDependencyLoaderTest.class);
        suite.addTestSuite(GwtMessageHandler.class);

Should this beGwtMessageHandlerTest.class? Is there a superfluous test class (GwtMessageHandler)?


flow-server/src/main/java/com/vaadin/flow/component/page/Page.java, line 363 at r6 (raw file):

     * supposed to return a JavaScript {@code Promise}.
     * <p>
     * No any change will be applied on the client side until resulting Promise

Grammar: "No any change..." -> "No change ...". Promise could be wrapped in <code>...</code> or {@code ...}


flow-server/src/main/java/com/vaadin/flow/shared/ui/Dependency.java, line 101 at r6 (raw file):

    /**
     * Creates a new dependency of the given type, to be loaded using JS
     * expression which is supposed to return a Promise.

Minor: Promise could be wrapped in {@code ...} or <code>...</code> for clarity.

Copy link
Contributor Author

@denis-anisimov denis-anisimov left a comment

Choose a reason for hiding this comment

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

Reviewable status: 3 unresolved discussions, 0 of 1 LGTMs obtained (waiting on @joheriks)


flow-client/src/main/java/com/vaadin/client/DependencyLoader.java, line 72 at r6 (raw file):

Previously, joheriks (Johannes Eriksson) wrote…

This object looks identical to EAGER_RESOURCE_LOAD_LISTENER and it does not seem stateful. Could a single object be used? (Methods inlineDependency and loadEagerDependency both refer to EAGER_RESOURCE_LOAD_LISTENER, and it looks to me like inlineDependency, loadEagerDependency and loadDynamicImport could be consolidated into a single method).

Very good points.
Though I didn't touch this pieces of code at all but it's worth to fix the parts which has not been changed in this PR at all.


flow-client/src/test-gwt/java/com/vaadin/client/GwtSuite.java, line 52 at r6 (raw file):

Previously, joheriks (Johannes Eriksson) wrote…

Should this beGwtMessageHandlerTest.class? Is there a superfluous test class (GwtMessageHandler)?

Arghhhh.
It was. It's an initial state. I've renamed it at some point.
Git merge also participated in this PR to make work on it terrible.

Oh my god.
It's even worse: there are both of them .
If was the worst PR ever.

Done.


flow-server/src/main/java/com/vaadin/flow/component/page/Page.java, line 363 at r6 (raw file):

Previously, joheriks (Johannes Eriksson) wrote…

Grammar: "No any change..." -> "No change ...". Promise could be wrapped in <code>...</code> or {@code ...}

Done.

Copy link
Contributor Author

@denis-anisimov denis-anisimov left a comment

Choose a reason for hiding this comment

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

Reviewable status: 3 unresolved discussions, 0 of 1 LGTMs obtained (waiting on @joheriks)


flow-client/src/main/java/com/vaadin/client/DependencyLoader.java, line 72 at r6 (raw file):

Previously, denis-anisimov (Denis) wrote…

Very good points.
Though I didn't touch this pieces of code at all but it's worth to fix the parts which has not been changed in this PR at all.

Done.

Copy link
Contributor

@joheriks joheriks left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 5 files at r7.
Reviewable status: 1 unresolved discussion, 0 of 1 LGTMs obtained (waiting on @denis-anisimov)


flow-client/src/test-gwt/java/com/vaadin/client/GwtMessageHandlerTest.java, line 160 at r7 (raw file):

        handler.handleJSON(object.cast());

        runDeferred(() -> {

Are the results of the assertions in the runDeferred blocks actually checked? I tried adding assertTrue(false); at this point but mvn verify still succeeded.

Copy link
Contributor Author

@denis-anisimov denis-anisimov left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 unresolved discussion, 0 of 1 LGTMs obtained (waiting on @joheriks)


flow-client/src/test-gwt/java/com/vaadin/client/GwtMessageHandlerTest.java, line 160 at r7 (raw file):

Previously, joheriks (Johannes Eriksson) wrote…

Are the results of the assertions in the runDeferred blocks actually checked? I tried adding assertTrue(false); at this point but mvn verify still succeeded.

Yes, it's not executed in the test though it has been working for me.
Not anymore.

That will delay this freaking stuff for several days more.
Cool.

Copy link
Member

@manolo manolo left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 unresolved discussion, 0 of 1 LGTMs obtained (waiting on @joheriks)


flow-client/src/test-gwt/java/com/vaadin/client/GwtMessageHandlerTest.java, line 160 at r7 (raw file):

Previously, denis-anisimov (Denis) wrote…

Yes, it's not executed in the test though it has been working for me.
Not anymore.

That will delay this freaking stuff for several days more.
Cool.

Not sure how this work, but IIUC, what you need to do here is to run the gwt test asynchronously, the pattern normally in GWT is to use the delayTestFinish() and finishTest() pattern (take a look to GwtApplicationConnectionTest

@ujoni ujoni added +1.0.0 and removed +0.1.0 labels Oct 3, 2019
Copy link
Contributor Author

@denis-anisimov denis-anisimov left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 unresolved discussion, 0 of 1 LGTMs obtained (waiting on @joheriks)


flow-client/src/test-gwt/java/com/vaadin/client/GwtMessageHandlerTest.java, line 160 at r7 (raw file):

Previously, manolo (Manuel Carrasco Moñino) wrote…

Not sure how this work, but IIUC, what you need to do here is to run the gwt test asynchronously, the pattern normally in GWT is to use the delayTestFinish() and finishTest() pattern (take a look to GwtApplicationConnectionTest

!!!!!!!!
Thanks a lot !!
That's exactly what I was looking for .
I've already found an ugly workaround but now it has no sense since it may
be done properly.
It looks like I was blind when I've been trying to find those methods by myself and failed.

Thanks you very much.

Copy link
Member

@manolo manolo left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 5 files at r2, 2 of 5 files at r3, 4 of 6 files at r4, 4 of 5 files at r7, 1 of 1 files at r8.
Reviewable status: 1 unresolved discussion, 0 of 1 LGTMs obtained (waiting on @joheriks)


flow-client/src/test-gwt/java/com/vaadin/client/GwtMessageHandlerTest.java, line 160 at r7 (raw file):

Previously, denis-anisimov (Denis) wrote…

!!!!!!!!
Thanks a lot !!
That's exactly what I was looking for .
I've already found an ugly workaround but now it has no sense since it may
be done properly.
It looks like I was blind when I've been trying to find those methods by myself and failed.

Thanks you very much.

👍

Copy link
Contributor

@joheriks joheriks left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 6 files at r4.
Reviewable status: :shipit: complete! all discussions resolved, 1 of 1 LGTMs obtained

@joheriks joheriks merged commit b7000f5 into master Oct 4, 2019
@joheriks joheriks deleted the issues/6577-page-loadDependency branch October 4, 2019 08:52
@joheriks joheriks added this to the 2.1.0.beta2 milestone Oct 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement a new type of dependency which may be loaded dynamically
5 participants