** Enforcement of efficient use of workloadClient APIs ** #92
vadimazarov
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
We are implementing new guidelines to ensure the correct use of methods provided by the @ms-fabric/workload-client npm package. Moving forward, we will be monitoring the frequency of usage of these methods and reaching out to developers whose code is inefficient in a way that surpasses a certain threshold.
Callback Registrations
In this sample workload, you will now see that in SampleWorkloadEditor.tsx, the methods that register callback functions are called once per session by calling them in the context of a useEffect hook. The previous implementation, without the useEffect hook, resulted in the callback functions being registered many times, on every rerender of the component.
Other Methods
Another example of efficient use of API methods can be found in the onCallSettingsGet method. This function is triggered only when a user clicks the corresponding button. Then, the workloadClient is used to fetch the workload settings. A much less efficient implementation, for example, would fetch the settings on every rerender of the component.
The following are methods that we have tracked issues with, in terms of the frequency of their usage:
workloadClient.navigation.onBeforeNavigate()
-- callback registrationworkloadClient.navigation.onAfterNavigate()
-- callback registrationworkloadClient.navigation.onNavigate()
-- callback registrationworkloadClient.settings.get()
workloadClient.itemSchedule.getItemJobHistory(GetItemJobHistoryParams)
workloadClient.auth.acquireAADToken(AcquireAccessTokenParams)
workloadClient.itemCrud.getItem(GetItemParams)
We request that you review your code and determine if it is behaving in the way you intended.
Thank you for your cooperation! :)
Beta Was this translation helpful? Give feedback.
All reactions