Open andres-kovalev opened 5 years ago
Another option is:
import createStorage from 'react-easy-flux';
const {
configureProvider,
useStorage
} = createStorage();
const Provider = configureProvider(reducer, middlewares);
Less preferable option:
const {
Provider,
useStorage
} = createStorage();
const App = () => (
<Provider reducer={ reducer } middlewares={ middlewares } storage={ storage }>
{ content }
</Provider>
);
Another option:
const configureStorage = createStorage();
const {
Provider,
useStorage
} = configureStorage(reducer, middlewares);
Looks like 1st option is a winner
Initially it was debatable - when to configure storage (pass
reducer
andmiddlewares
) when creating storage or putting context (Provider
) into react tree. But now (especially after related #8) it's quite obvious - storage configuration should be moved toProvider
level. It became more flexible and will provide ability to use the same context with different configurations. So, seems it should be implemented in redux-like way: