A plugin for NGXS that eliminates action boilerplate by using decorators to directly connect components to state methods.
@ngxs-labs/emitter is a plugin for NGXS, a state management library for Angular. It introduces the Emitter-Receiver (ER) pattern, which allows developers to update state directly from components using decorators, eliminating the need to create and manage traditional action files. This reduces boilerplate and simplifies the state update flow.
Angular developers using NGXS for state management who want to reduce boilerplate and simplify their codebase by avoiding action definitions.
It offers a cleaner, more direct way to handle state updates by removing the action layer, which reduces file count and cognitive overhead while maintaining type safety and testability.
:octopus: New pattern that provides the opportunity to feel free from actions
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Eliminates the need for separate action files by using @Emitter() and @Receiver() decorators to connect components directly to state methods, as shown in the counter example where actions are bypassed.
Supports generics like Emittable<T> for payload typing, ensuring compile-time validation and reducing runtime errors, as demonstrated in the custom payload examples.
Includes StoreTestBedModule for easy unit testing without mocked components, allowing direct emission via EmitterService in tests, as highlighted in the TDD section.
Provides RxJS operators such as ofEmittableDispatched to react to state update events, offering fine-grained control over emitter lifecycles, as detailed in the lifecycle examples.
Introduces the non-standard Emitter-Receiver pattern, which may confuse developers familiar with traditional Redux or NGXS action workflows and require team retraining.
Bypassing actions can interfere with NGXS devtools and plugins that depend on action types for monitoring, as admitted in the README where custom types are needed for debugging.
Requires using Injector for dependency injection in static state methods, which is less intuitive than Angular's standard constructor injection and adds setup overhead.