Skip to content

Conversation

@jdegand
Copy link

@jdegand jdegand commented Sep 2, 2025

Closes #213

With these changes, you no longer get a blank screen when using Redux DevTools extension.

manfredsteyer and others added 4 commits September 1, 2025 16:15
This makes `rxMutation` a fully autonomous function
which can also be used entirely independently of the
SignalStore.

It also exposes the following additional properties:
- `isSuccess`
- `hasValue`
- `value`
@jdegand
Copy link
Author

jdegand commented Sep 2, 2025

On Line 26 in with-devtools, EXISTING_NAMES is unused. I left it alone (I can't comment on that line in a code review).

I removed the unneeded id variable in with-devtools in this PR. I noticed this during the course of my investigation of the error.

@rainerhahnekamp
Copy link
Collaborator

I am not Michael, but I took a quick look. Would it be possible to construct a test case that causes the bug?

@michael-small
Copy link
Collaborator

On Line 26 in with-devtools, EXISTING_NAMES is unused. I left it alone (I can't comment on that line in a code review).

Sounds good to remove for me

I removed the unneeded id variable in with-devtools in this PR. I noticed this during the course of my investigation of the error.

Good catch

Copy link
Collaborator

@michael-small michael-small left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for getting to this as I had not yet. This is cleaner than what I was considering doing.

I think it looks good. Approved on the assumption that a test case comes along. edit: thank you

@michael-small michael-small added the bug Something isn't working label Sep 3, 2025
});

function createTrackerMock(): Tracker {
const onChangeMock = jest.fn();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't think about how this will translate to Vitest, but it should be fine.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this:

(tracker.onChange as ReturnType<typeof vi.fn>).mockImplementation((cb) => {
  cb({ [id]: { count: 42 } });
});

@@ -0,0 +1,96 @@
import { PLATFORM_ID } from '@angular/core';
Copy link
Author

@jdegand jdegand Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a separate test file. I did look at other tests and noticed deprecated use of TestBed.flushEffects() should be able to be quickly replaced with TestBed.tick(). Best to fix during Vitest conversion PR or separate PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran all of these tests against the current main branch.
All of them passed except "should handle extension absence gracefully".
That test failed only because it checks whether a warning message is shown when
extensions aren’t available.

Issue #213, however, shows an error from renameStore, which points to a
different problem than the one addressed in this PR.

We need a test that reproduces the reported error.

Other than that, I do think that you don't have to create a separate file.
Adding it to connecting.spec.ts should work.

Copy link
Collaborator

@rainerhahnekamp rainerhahnekamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to spoil the party, but there are a few things that need attention:

  • The actual bug doesn’t seem to be fixed. I left a comment in the tests, but
    instead of addressing that, you added extra warning messages (which had been
    removed on purpose before). Also, there is still no test that reproduces the
    reported issue.
  • I generally appreciate PRs that include refactorings. The problem here is
    that by applying a different style, I also have to review those changes,
    which shifts the focus away from the bug fix. If you want to do refactorings,
    please open them in a separate PR.

Once we have a test that reproduces the bug (and fixes it), I think we’ll be on the right
track.

connectSpy = jest.fn(() => ({ send: sendSpy }));
(window as any).__REDUX_DEVTOOLS_EXTENSION__ = { connect: connectSpy };

TestBed.resetTestingModule();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need that?

const name = this.#stores[id].name;
const name = this.#stores[id]?.name;

this.#stores = Object.entries(this.#stores).reduce(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can discuss conventional vs. use-case-specific naming - both have their
pros and cons. In the end, it’s a matter of style.

For the sake of consistency, please revert to newStore here.

newState[name] = state;
}
return newState;
(acc, [storeName, state]) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

acc -> newState

},
{} as StoreRegistry,
);
this.#stores = Object.entries(this.#stores).reduce((acc, [key, value]) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newStore & id

newState[storeName] = state;
}
return newState;
(acc, [storeName, state]) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newState

}

getNextId() {
getNextId(): string {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally speaking, when you implement a fix or so, try
not to do too much refactoring. It makes the review process
longer...especially if we have a disagreement on how the
refactoring was done.

We can leave that, but we should have a general discussion if public
methods should explicitely define the return type.


const dummyConnection: Connection = {
send: () => void true,
send: () => true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you change the return type?

#initDevtoolsConnection(): Connection {
const extension = window.__REDUX_DEVTOOLS_EXTENSION__;
if (!extension) {
console.warn('[DevtoolsSyncer] Redux DevTools extension not found.');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it can be annoying to throw warnings if DevTools are not
there. Especially since they can also be enabled in production.

constructor() {
if (!this.#isBrowser) {
return;
console.warn(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No warnings if we are on the server. We had
this before and users were complaining that
we are filling up their logs.

@@ -0,0 +1,96 @@
import { PLATFORM_ID } from '@angular/core';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran all of these tests against the current main branch.
All of them passed except "should handle extension absence gracefully".
That test failed only because it checks whether a warning message is shown when
extensions aren’t available.

Issue #213, however, shows an error from renameStore, which points to a
different problem than the one addressed in this PR.

We need a test that reproduces the reported error.

Other than that, I do think that you don't have to create a separate file.
Adding it to connecting.spec.ts should work.

@jdegand
Copy link
Author

jdegand commented Sep 6, 2025

Closing in favor of #234.

@jdegand jdegand closed this Sep 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

withDevTools() not working in demo app?

4 participants