oncall
oncall copied to clipboard
Prevent using responses from MobX actions
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.
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:!