-
Notifications
You must be signed in to change notification settings - Fork 306
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
feat: use @lit/task
to schedule async data fetching
#2912
Conversation
🚀 New react-contoso sample application deployed here |
1 similar comment
🚀 New react-contoso sample application deployed here |
📖 The updated storybook is available here |
1 similar comment
📖 The updated storybook is available here |
🚀 New react-contoso sample application deployed here |
📖 The updated storybook is available here |
🚀 New react-contoso sample application deployed here |
📖 The updated storybook is available here |
🚀 New react-contoso sample application deployed here |
📖 The updated storybook is available here |
🚀 New react-contoso sample application deployed here |
📖 The updated storybook is available here |
📖 The updated storybook is available here |
🚀 New react-contoso sample application deployed here |
📖 The updated storybook is available here |
🚀 New react-contoso sample application deployed here |
🚀 New react-contoso sample application deployed here |
📖 The updated storybook is available here |
After review, when the initial load of the Teams channel picker happens, we should have a loading state withing the flyout and not in place of the input. |
🚀 New react-contoso sample application deployed here |
📖 The updated storybook is available here |
🚀 New react-contoso sample application deployed here |
📖 The updated storybook is available here |
🚀 New react-contoso sample application deployed here |
|
📖 The updated storybook is available here |
@musale can you please take a look at this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. There are nice refactors with this introduction that reduce code well.
Closes #2861
PR Type
Description of the changes
This PR introduces a new approach to loading component state via async calls.
The approach provided in the
MgtBaseComponent
andMgtTemplatedComponent
relied on manually calling the requestUpdate method and exposing a requestStateUpdate method to manually load external state via an http call.This had a side effect of scheduling updates during an update cycle which is inefficient and results in a warning emitted to the console when running in developer mode.
The new approach introduces two replacement base classes
MgtBaseTaskComponent
andMgtTemplatedTaskComponent
which should be used to replace their respective predecessors.@lit/task
is used to wrap up the existingloadState
method in each component, this is supplied byMgtBaseTaskComponent
. Implementing classes must implement:args: () => unknown[]
instance method. The array returned should contain all of the reactive properties on the object which when changed will trigger loadState method to be called. This array should contain theproviderState
property from the base class.renderContent: () => TemplateResult
the existingrender
method should be renamed to this. The implementation of therender
method is provided by each of the base classes and provides default implementations for rendering while the task execution is in progress and if an error occurs. You may of course provide component specific overrides for any of these methods as needed.@property
decorators on fields with custom accessor methods should be moved to decorate the setter method rather than the getter as was done previously. If a field is callingrequestStateUpdate
then it should be present in the array returned from theargs
methodThe existing base classes will be marked as
@deprected
when the migration is complete and may be removed in a future version.Testing of these changes needs to be done locally, The react-contoso application is a good test bed, however it's important to try navigating away and back to a page with the component being tested as sometimes the warning doesn't occur on a full page reload.
As this is a large change I'd recommend reviewing the changes by looking at each commit as a change to help with chunking this. after the initial commits getting the pattern set I've kept the changes in a single commit to cover a single component or set of related components.
PR checklist
yarn build
) and changes have been tested in at least two supported browsers (Edge + non-Chromium based browser)yarn setLicense
)Other information
Converted components: