unirakun / k-ramel

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

give `store` to `matcher` (if not already the case) #297

Closed fabienjuif closed 5 years ago

fabienjuif commented 5 years ago

So a user can do when((action, store) => action.type === store.data.shows.SET)

fabienjuif commented 5 years ago

Maybe this is better to have when(match(store.data.shows.set))

and match helper would do this:

const match = (matcher) => (action) => {
  if (!matcher.krmlAction) return false
  return action.type === store.data.shows.set.TYPE
}

So everytime a TYPE is set to a function this is usable (not only with krf for a near future).

But if we do this, we have to rewrite part of toContext.js to move those types

fabienjuif commented 5 years ago

Nevermind, finally I think this is better to stick to k-redux-factory. So users that know k-redux-factory don't have to switch their mind when they dev with/for k-ramel.

So we come back to when((action, store) => action.type === store.data.shows.SET)

fabienjuif commented 5 years ago

This is already possible, I updated the documentation to add some matcher example.