unirakun / k-ramel

State manager for your components apps, the safe and easy way
MIT License
21 stars 5 forks source link

having possibility to load the reducers dynamically #102

Open bpetetot opened 6 years ago

bpetetot commented 6 years ago

k-ramel already propose the ability to load listeners dynamically.

Do you think that it could also load some reducers dynamically in order to have a complete separation of some screens ?

For example, in my app, I have an admin page that managing all my application users. And I have specific reducers (users data, admin screens data) specific to that page. So I could have a container loading k-ramel reducers and listeners specific to it :

import { updateStore, when } from '@k-ramel/react'
import AdminPage from './AdminPage'

updateStore({
  data: { users: { type: 'keyValue', id: 'uid' } },
  ui: { admin: { type: 'simpleObject' } },
}, [
  when('MY_ADMIN_ACTION')(() => { /* do something */ })
]})(AdminPage)

And it could be a great optimisation for apps using code splitting (dynamic imports).

fabienjuif commented 6 years ago

Yes we could I thank about it a lot. All of this is related to:

(#94/#102/#72) this is about hot loading reducers / configurations

But this is a big issue to think about since:

fabienjuif commented 6 years ago

An other thing we can do is to create a local store for your screen. We can get inspiration from https://github.com/alakarteio/multi-store-redux-saga so all events pass through parent store.