-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…#55648) Previously `afterRender` and `afterNextRender` allowed the user to pass a phase to run the callback in as part of the `AfterRenderOptions`. This worked, but made it cumbersome to coordinate work between phases. ```ts let size: DOMRect|null = null; afterRender(() => { size = nativeEl.getBoundingClientRect(); }, {phase: AfterRenderPhase.EarlyRead}); afterRender(() => { otherNativeEl.style.width = size!.width + 'px'; }, {phase: AfterRenderPhase.Write}); ``` This PR replaces the old phases API with a new one that allows passing a callback per phase in a single `afterRender` / `afterNextRender` call. The return value of each phase's callback is passed to the subsequent callbacks that were part of that `afterRender` call. ```ts afterRender({ earlyRead: () => nativeEl.getBoundingClientRect(), write: (rect) => { otherNativeEl.style.width = rect.width + 'px'; } }); ``` This API also retains the ability to pass a single callback, which will be run in the `mixedReadWrite` phase. ```ts afterRender(() => { // read some stuff ... // write some stuff ... }); ``` PR Close #55648
- Loading branch information
Showing
5 changed files
with
535 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.