oncall icon indicating copy to clipboard operation
oncall copied to clipboard

Prevent using responses from MobX actions

Open brojd opened this issue 1 year ago • 1 comments

Currently we have MobX actions that are making http request and then are returning response (sometimes observables are updated in the middle, sometimes not). For example:

 @action
 async saveChannelFilter(channelFilterId: ChannelFilter['id'], data: Partial<ChannelFilter>) {
   const response = await makeRequest(`/channel_filters/${channelFilterId}/`, {
     method: 'PUT',
     data,
   });


   runInAction(() => {
     this.channelFilters = {
       ...this.channelFilters,
       [response.id]: response,
     };
   });


   return response;
 }

We should get rid of returning data from MobX actions and instead components should consume observables from stores directly.

brojd avatar Jan 23 '24 10:01 brojd

The current version of Grafana OnCall, at the time this issue was opened, is v1.3.90. If your issue pertains to an older version of Grafana OnCall, please be sure to list it in the PR description. Thank you :smile:!

github-actions[bot] avatar Jan 23 '24 10:01 github-actions[bot]