Skip to content

feat(devtools): create tracked event and tracked event group using proxy#304

Open
ahmedwelhakim wants to merge 1 commit into
angular-architects:mainfrom
ahmedwelhakim:main
Open

feat(devtools): create tracked event and tracked event group using proxy#304
ahmedwelhakim wants to merge 1 commit into
angular-architects:mainfrom
ahmedwelhakim:main

Conversation

@ahmedwelhakim
Copy link
Copy Markdown

Proposal: Add trackedEvent and trackedEventGroup

Motivation

While working with event-driven patterns in NgRx Signal Store, debugging and tracing dispatched events can become difficult as the application grows.
As withTrackedReducer doesn't detect all dispatched events, only used ones in reducer.

So this proposal introduces:

  • trackedEvent to be used instead of event
  • trackedEventGroup to be used instead of eventGroup

as lightweight wrappers around the existing event creators to track dispatched events using proxy without needing the withTrackedReducer.


Goals

  • Preserve the exact same API as the original event creators
  • Add transparent event dispatch tracking
  • Keep typings fully compatible with existing NgRx Signal Store patterns
  • Avoid runtime overhead unless events are actually dispatched

Proposed API

trackedEvent

export const loadBooks = trackedEvent('[Books] Load Books');
loadBooks();

Devtool action:

[Books] Load Books

trackedEventGroup

export const bookEvents = trackedEventGroup({
  source: 'Book Store',
  events: {
    loadBooks: type<void>(),
    bookSelected: type<{ bookId: string }>(),
  },
});
bookEvents.bookSelected({ bookId: '1' });

Devtool:

[Book Store] bookSelected

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