-
Notifications
You must be signed in to change notification settings - Fork 93
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 signalSlice #135
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 512eb4d. 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 targetsSent with 💌 from NxCloud. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nits but approved
@all-contributors please add @joshuamorony for code |
I've put up a pull request to add @joshuamorony! 🎉 |
Co-authored-by: Chau Tran <nartc7789@gmail.com>
This was created in collaboration with Chau, it adds
signalSlice
which is loosely inspired by thecreateSlice
API from Redux Toolkit. The general idea is that it allows you to declaratively create a "slice" of state. This state will be available as a readonly signal.The key motivation, and what makes this declarative, is that all the ways for updating this signal are declared upfront with
sources
andreducers
. It is not possible to imperatively update the state.This PR also makes minor changes to
connect
in order to expose types that are shared by this utility.Example using all API features:
Key features:
this.state.remove(id)
)For my own purposes this API is "feature complete" and does everything I need but I'm very open to comments/revisions/improvements.