bcherny / undux

⚡️ Dead simple state for React. Now with Hooks support.
https://undux.org
MIT License
1.49k stars 31 forks source link

How to use withLogger with namespaced state and effects? #82

Closed AfflatusX closed 5 years ago

AfflatusX commented 5 years ago

Looks like withLogger only takes single store definition?

bcherny commented 5 years ago

It's a little ugly, but you can do something like:

createConnectedStoreAs(initialStates, stores => {
  return withEffects({
    a: withLogger(stores.a),
    b: withLogger(stores.b)
  })
})

createConnectedStoreAs's second argument is any function that takes an object of stores, and returns an object of stores.