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(framework): Deprecate RenderScheduler in favor of Render.js #2728

Merged
merged 8 commits into from
Feb 1, 2021

Conversation

vladitasev
Copy link
Contributor

@vladitasev vladitasev commented Jan 26, 2021

Changes:

  • New module: Render.js that implements all functionality that used to be in RenderScheduler.js. This allows the code to be tree-shaken, unlike as it was before (with a static class).
  • whenFinished renamed to renderFinished.
  • RenderScheduler.js is deprecated, although not deleted yet, and it proxies the 3 important functions that external users normally call: renderImmediately, renderDeferred and whenFinished.
  • The register and deregister functions have been merged with renderImmediately and cancelRender respectively and no longer exist.
  • The reRenderAllUI5Elements function is now async and awaits for renderFinished internally. This was changed because normally when this function was called, renderFinished was called on the next line.
  • All test assets have been reworked to access renderFinished from the window["sap-ui-webcomponents-bundle"] global variable rather than from the RenderScheduler global variable.

Additionally, upgraded Chromedriver to version 88.

BREAKING CHANGES:

  • RenderScheduler.js deprecated. The file will be deleted in a future release. If you were using some of its methods, import these methods from the new Render.js module. For example, if you were using:
import RenderScheduler from "@ui5/webcomponents-base/dist/RenderScheduler.js";
RenderScheduler.renderImmediately(myComponent);
RenderScheduler.renderDeferred(myComponent);
await RenderScheduler.whenFinished();

change to:

import { renderFinished, renderImmediately, renderDeferred } from "@ui5/webcomponents-base/dist/Render.js";
renderImmediately(myComponent);
renderDeferred(myComponent);
await renderFinished();
  • whenFinished from RenderScheduler.js renamed to renderFinished and now exported by Render.js. For usage, see the previous example


const whenFinished = async () => {
await whenAllCustomElementsAreDefined();
await whenDOMUpdated();
Copy link
Contributor

Choose a reason for hiding this comment

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

not related to this change, but I think we should improve this with a loop, as the DOM Update promise might result in more undefined custom elements.


// Schedule a rendering task
await RenderScheduler.scheduleRenderTask();
await renderDeferred(webComponent);
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a warning in the console, otherwise it is too easy to miss.

@@ -59,7 +59,7 @@ class StaticAreaItem extends HTMLElement {
this._rendered = true;
updateShadowRoot(this.ownerElement, true);
}
await RenderScheduler.whenDOMUpdated(); // Wait for the content of the ui5-static-area-item to be rendered
await whenFinished(); // Wait for the content of the ui5-static-area-item to be rendered
Copy link
Contributor

Choose a reason for hiding this comment

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

Without the RenderSchduler, whenFinished sounds too generic.

I also think the when... sounds good when followed by a then...

Maybe we can drop the when a use the render verb, something like
await renderFinished()

@vladitasev vladitasev merged commit bc78857 into master Feb 1, 2021
@vladitasev vladitasev deleted the deprecate-render-scheduler branch February 1, 2021 06:40
alexandar-mitsev pushed a commit to alexandar-mitsev/ui5-webcomponents that referenced this pull request Feb 1, 2021
NHristov-sap pushed a commit to NHristov-sap/ui5-webcomponents that referenced this pull request Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants