Refactor: Modernize budget viewer state with Signals#180
Open
NyamburaSandra wants to merge 1 commit intoitalanta:mainfrom
Open
Refactor: Modernize budget viewer state with Signals#180NyamburaSandra wants to merge 1 commit intoitalanta:mainfrom
NyamburaSandra wants to merge 1 commit intoitalanta:mainfrom
Conversation
… to Angular Signals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
** Briefly explain how you went about this assignment and the key benefits of using Signals over the previous RxJS approach in this UI scenario.**
• Explain how you understand the difference in coding styles between the two.
When using RxJS, the coding style is more imperative and stream-based.
• Explain how signals and observables works and if there’s a fundamental difference between the two.
Signals
Always hold a current value. Are synchronous and pull-based. Update values instantly. Trigger dependent computations automatically. Work naturally in templates
Observables
Don’t hold values by default. Are asynchronous and push-based. Require subscriptions to access values. Use operators to transform data. Suitable for event streams, multi-value sequences, or async sources
Signals represent state, while Observables represent asynchronous data streams. Signals excel in UI state management. Observables excel in handling things like HTTP requests, user events, and data streams.
They complement each other, and Angular now provides tools (toSignal, fromSignal) to bridge both paradigms.
• Mention an example of another coding paradighm or style you’ve used in the past. What is better/worse about that one?
React Hooks, especially useState and useEffect. The Signals pattern feels similar because both track dependencies automatically and update the UI reactively. However its
Better in Signals
No dependency arrays (which are a common source of bugs in React). Automatic dependency tracking
Fewer re-renders due to fine-grained updates. More predictable state updates
Better in React Hooks
Larger ecosystem and familiarity. Very flexible functional programming model
Angular signals provide a more predictable and less error-prone reactive model compared to the Hook-based reactivity in React.