Redux - multiple stores, why not?

前端 未结 6 2000
暖寄归人
暖寄归人 2020-11-28 17:40

As a note: I\'ve read the docs for Redux (Baobab, too), and I\'ve done a fair share of Googling & testing.

Why is it so strongly suggested that a Redux a

6条回答
  •  我在风中等你
    2020-11-28 17:45

    In some very large enterprise apps with hundreds or thousands of reducers, it's often useful to think of different areas of the app as entirely separate apps. In those cases (where it really is multiple apps that share a domain name), I use multiple stores.

    For example, I tend to treat the following common functionality areas as separate apps:

    • Admin
    • Analytics / data vis dashboards
    • Billing management & purchase flows
    • Enterprise account team/permission management

    If any of those things are small, just keep them as part of the main app. If they grow very large (as some enterprise account management & analytics tools do), split them out.

    The best way to manage very large apps is to treat them like a composition of many smaller apps.

    If your app is less than say ~50k LOC, you should probably ignore this advice and follow Dan's advice, instead.

    If your app is more than 1 Million LOC, you should probably be splitting out mini-apps, even if you maintain them in a mono repo.

提交回复
热议问题