mattermost / mattermost-redux

Redux for Mattermost
Apache License 2.0
200 stars 386 forks source link

Proposal: Introduce EPICS to handle side effects from redux actions #1417

Closed AGMETEOR closed 3 years ago

AGMETEOR commented 3 years ago

Summary

Motivation Ticket 1 Motivation Ticket 2

Example 1

In Motivation Ticket 2, we had a bug caused by this flow. First, at boot time, if we had a cloud licence we would load subscriptionStats here. The bug occurred when, at boot time, the license was not cloud, and then later a user witches the license to cloud. This means there'll be components expecting to use subscriptionStats but they were not loaded. The components were nolonger working properly. To fix, we might have to go into each of the components and in compnentDidMount or useEffect hook check whether the subscriptionStats exist and then fetch them.

A more compact and predictable solution would be to listen to redux events and then react to them. In this demo PR, I use redux-observable library and rxjs to listen to UPLOAD_LISENCE_SUCCESS redux action and then as a side effect trigger fetching of subscriptionStats if the uploaded lisence is a Cloud one.

In Motivation Ticket 1, the solution was to listen to a webhook event and then update the data. This can also easily be solved with an appropriate epic.

Ticket Link

None

hmhealey commented 3 years ago

Hey Allan. Just a heads up that this repo is technically frozen right now pending it being moved into the webapp with https://github.com/mattermost/mattermost-webapp/pull/7723.

AGMETEOR commented 3 years ago

Hey Allan. Just a heads up that this repo is technically frozen right now pending it being moved into the webapp with mattermost/mattermost-webapp#7723.

Hey Harrison, thanks for the heads up.

hmhealey commented 3 years ago

For the Epics themselves, we'd definitely be interested in discussing them with the web guild. I haven't looked into Epics myself, but we're actually going to be trying out Redux Sagas at some point since Jesse has previous experience with them. It sounds like they'll be able to fix similar problems too!

AGMETEOR commented 3 years ago

For the Epics themselves, we'd definitely be interested in discussing them with the web guild. I haven't looked into Epics myself, but we're actually going to be trying out Redux Sagas at some point since Jesse has previous experience with them. It sounds like they'll be able to fix similar problems too!

Yes. I think redux saga and redux-observable do the same thing.

hmhealey commented 3 years ago

@AGMETEOR mattermost-redux has been merged into the web app now, so you can feel free to resubmit this there.