Provide action to subscribed functions.#120
Provide action to subscribed functions.#120AndrewSouthpaw wants to merge 1 commit intoreduxjs:masterfrom
Conversation
ohtangza
left a comment
There was a problem hiding this comment.
This code itself should work well with this test.
One thing I worried is that this library does not seem to guarantee the full functionality of redux's store.
|
Thanks for the review, @ohtangza. I would love to get this merged so I can stop using my forked version of this repo. 😆 |
|
@AndrewSouthpaw My pleasure, let's wait for @arnaudbenard response then. |
|
I'd love to see this happen. |
|
I don't think it follows the redux design, check this https://github.com/reactjs/redux/blob/master/docs/faq/DesignDecisions.md#does-not-pass-state-action-to-subscribers @dmitry-zaets what do you think? |
|
That's true... it does break from the design. I thought it wouldn't be critical to follow that same design choice, since this is a mock store intended for testing purposes. The state never changes anyway, so the concept of batching isn't particularly relevant, while it can be useful in tests to subscribe to particular actions firing in the store. |
|
Ping. :) |
|
|
||
| for (let i = 0; i < listeners.length; i++) { | ||
| listeners[i]() | ||
| listeners[i](action) |
There was a problem hiding this comment.
Should this action be passed in here after removing the type property?
There was a problem hiding this comment.
Unless there's a huge demand for it, I'd leave the type property, it gives more rich info to any listeners in test.
|
If not this solution, is there an alternative way that you could still get the state passed in. that would be helpful in testing components that are wrapped in |
|
@abe4mvp If I understand you correctly, that would require a working reducer to be hooked into the store, which is currently not possible. I've actually extended this repo to allow that, so I find it helpful, but... yeah. Not sure if that's beyond what would be considered "proper" for this repo. |
|
Ping? |
|
I implemented this in my TypeScript fork |
It's useful among subscribers to know which action is being dispatched. This PR provides the action object to subscribed functions.