Skip to content

Conversation

@rainerhahnekamp
Copy link
Collaborator

Summary

This PR introduces withTrackedReducer as an alternative approach to tracking reducer-based state changes in Redux DevTools. It addresses limitations in the original withEventsTracking implementation.

The original implementation (based on #231) attempted to automatically track reducer-based state changes via the glitch tracker. However, this approach has fundamental limitations that cannot be resolved with the specified approach.

Several edge cases are documented in the skipped tests within with-events-tracking.spec.ts.

This PR introduces an alternative way, where end users have to use the wrapperd function withTrackedReducer which calls internally updateState using the event's name.

If we proceed with this approach, the following items need to be completed:

  • Update documentation to explain withTrackedReducer usage and when to use it vs withReducer
  • Update demo applications to showcase the new API
  • Remove or deprecate code from the initial withEventsTracking approach (if applicable)
  • Add validation/runtime checks to ensure withTrackedReducer is only used with stores that have devtools and glitch tracking enabled

@michael-small
Copy link
Collaborator

I did a preliminary review for now and will give a more formal one in the evening. Looks good though.

One piece missing at the moment: some sort of documentation reference

Co-authored-by: Michael Small <33669563+michael-small@users.noreply.github.com>
@rainerhahnekamp
Copy link
Collaborator Author

@michael-small @wolfmanfx

I see it as temporarily. In the end, we need support for meta-reducers in the core...

@michael-small
Copy link
Collaborator

I see it as temporarily. In the end, we need support for meta-reducers in the core...

In that respect, I think this code/approach as-is minus the outstanding items seems legit. But with those outstanding items, I defer to @wolfmanfx on the outstanding considerations. I imagine there will be some more reviewing opportunity then.

Removed withEventsTracking.
Use withTrackedReducer instead for automatic DevTools action naming from events.

- Remove withEventsTracking feature and its test file
- Export withTrackedReducer as the replacement
- Remove unused onInit/DevtoolsHookContext from devtools types
- Remove devtoolsEventsTracker and eventsTracking option
- Update demo app to use withTrackedReducer
@wolfmanfx
Copy link
Collaborator

@rainerhahnekamp I have updated / cleaned the branch. I also vote for the temp solution with the "withTrackedReducer".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants