Skip to content

Conversation

@markostanimirovic
Copy link
Member

@markostanimirovic markostanimirovic commented Nov 16, 2025

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Closes #4776

What is the new behavior?

// === providing scoped dispatcher: ===
{ providers: [provideDispatcher()] }

// === dispatching events to the parent/global scope: ===
// scope values: 'self' | 'parent' | 'global' ('self' by default)

const event1 = event('event1');
const event2 = event('event2');

// using Dispatcher:
const dispatcher = inject(Dispatcher);
dispatcher.dispatch(event1(), { scope: 'parent' });

// using injectDispatch:
const dispatch = injectDispatch({ event1 });
dispatch({ scope: 'global' }).event1();

// using toScope:
withEffects((_, events = inject(Events)) => ({
  $: events.on(event1).pipe(
    map(() => [event2(), toScope({ 'parent' })]),
  ),
}))

// using mapToScope:
withEffects((_, events = inject(Events)) => ({
  $: events.on(event1).pipe(
    map(() => event2()),
    mapToScope('global'),
  ),
}))

Does this PR introduce a breaking change?

[ ] Yes
[x] No

@netlify
Copy link

netlify bot commented Nov 16, 2025

Deploy Preview for ngrx-io canceled.

Name Link
🔨 Latest commit 854abe4
🔍 Latest deploy log https://app.netlify.com/projects/ngrx-io/deploys/6925f1c78957040008b80369

@netlify
Copy link

netlify bot commented Nov 16, 2025

Deploy Preview for ngrx-site-v19 ready!

Name Link
🔨 Latest commit 854abe4
🔍 Latest deploy log https://app.netlify.com/projects/ngrx-site-v19/deploys/6925f1c71310c30008ed62aa
😎 Deploy Preview https://deploy-preview-4997--ngrx-site-v19.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

@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.

Will you provide the updated documentation in a separate PR?

@markostanimirovic
Copy link
Member Author

@rainerhahnekamp Yes, I'll add a new section 'Scoped Events' without changing existing content from the Events page because the previous behavior remained the same.

mapToScope,
toScope,
} from './event-scope';
export { Events, ReducerEvents } from './events-service';
Copy link
Contributor

Choose a reason for hiding this comment

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

That is important for the event tracker in the toolkit. 👍

Copy link
Contributor

@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.

LGTM 👍

Copy link
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

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

Lovely! 🤩

@markostanimirovic markostanimirovic merged commit c719d19 into main Nov 25, 2025
14 checks passed
@markostanimirovic markostanimirovic deleted the feat/signals/provide-support-for-scoped-events branch November 25, 2025 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@ngrx/signals/events: Provide Support for Scoped Events

4 participants