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

feat(signal-slice): allow supplying external subjects as reducers #152

Merged

Conversation

joshuamorony
Copy link
Contributor

This deals with situations where you need your sources to react to actions. These actions need to be defined as external subjects as the sources can not reference the internally created actions:

const trigger$ = new Subject<void>();
const state = signalSlice({
  initialState,
  sources: [trigger$.pipe(map(() => ({ age: testAge })))],
  reducers: {
    trigger: trigger$,
  },
});

state.trigger();

Allowing the subject to be supplied as a reducer means you can still access all of your actions on the state object, e.g:

state.trigger();

instead of needing to trigger some actions via the external subject:

trigger$.next();

Copy link

nx-cloud bot commented Nov 15, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 31f91d4. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


⌛ The following targets are in progress

✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

@nartc nartc enabled auto-merge (squash) November 16, 2023 14:49
@nartc nartc merged commit 7df93d3 into ngxtension:main Nov 16, 2023
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.

2 participants