hippware / rn-chat

MIT License
5 stars 0 forks source link

[dev] [discussion] think outside the MST box #4889

Open southerneer opened 4 years ago

southerneer commented 4 years ago

Spurred by discussion here: https://github.com/hippware/rn-chat/pull/4854. I believe we're overusing MST and it makes our codebase overly complicated.

MST is perfectly adequate for our base data structures (bot, profile, chat, etc) since these structures can change often in the lifecycle of a user session, are very inter-dependent, and need to be persisted across app reloads. MST's features give us solutions to those problems more or less "for free".

There are other pieces of state (permissions for example) that don't change often, don't require persistence, and don't depend on other parts of the state tree. Using MST for this "simpler" state has side-effects and requires hacks that we should seek to eliminate.

It is this "simpler" state that I propose to move out of MST and into either vanilla mobx or React state (or whatever else makes sense). Some candidates for this change:

We already have some stores (like ReportStore) that are written with vanilla Mobx that are good examples of how we can convert the stores I mentioned above.

cc @aksonov @bengtan

bengtan commented 4 years ago

We talked about this in a meeting last night.

Does this ticket still need to be open?