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): add effects config #141

Merged
merged 8 commits into from
Nov 9, 2023

Conversation

joshuamorony
Copy link
Contributor

This adds an effects config to signalSlice. It uses the standard signal effect internally, this just allows you to define your effects within the signalSlice definition rather than having to define them separately in a constructor or field initialiser:

state = signalSlice({
	initialState: this.initialState,
	sources: [this.sources$],
	reducers: {
		add: (state, checklist: AddChecklist) => ({
			checklists: [...state.checklists, this.addIdToChecklist(checklist)],
		}),
	},
	effects: (state) => ({
		init: () => {
			console.log('hello');
		},
		saveChecklists: () => {
			// side effect to save checklists
			console.log(state.checklists());
		},
	}),
});

Note that I have added but disabled tests for this feature pending the ability to use flushEffects

Copy link

nx-cloud bot commented Nov 9, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit d4f2d41. 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 merged commit 5b01712 into ngxtension:main Nov 9, 2023
6 checks 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.

None yet

2 participants