Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(devtools): extract tracking logic from DevtoolsSyncer #122

Conversation

rainerhahnekamp
Copy link
Collaborator

This is a pre-requisite for withGlitchTracking() feature.

DefaultTracker will track the states via an effect, but it is possible to override it with another tracker implementation per SignalStore.

At the moment, there is just one implementation, but withGlitchTracking() will follow in the next commit.

This is a pre-requisite for `withGlitchTracking()` feature.

`DefaultTracker` will track the states via an `effect`, but it
is possible to override it with another tracker implementation
per SignalStore.

At the moment, there is just one implementation, but `withGlitchTracking()`
will follow in the next commit.
It tracks all state changes of the State, including intermediary updates
that are typically suppressed by Angular's glitch-free mechanism.

This feature is especially useful for debugging.

Example:

```typescript
 const Store = signalStore(
  { providedIn: 'root' },
  withState({ count: 0 }),
  withDevtools('counter', withGlitchTracking()),
  withMethods((store) => ({
    increase: () =>
      patchState(store, (value) => ({ count: value.count + 1 }))
  }))
);

// would show up in the DevTools with value 0
const store = inject(Store);

store.increase(); // would show up in the DevTools with value 1
store.increase(); // would show up in the DevTools with value 2
store.increase(); // would show up in the DevTools with value 3
```
@rainerhahnekamp rainerhahnekamp marked this pull request as ready for review January 8, 2025 22:14
@rainerhahnekamp rainerhahnekamp merged commit fc972d5 into angular-architects:main Jan 8, 2025
1 check passed
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.

1 participant