Refactor: Modernize budget viewer state with Signals#190
Open
EstherNyumu wants to merge 2 commits intoitalanta:mainfrom
Open
Refactor: Modernize budget viewer state with Signals#190EstherNyumu wants to merge 2 commits intoitalanta:mainfrom
EstherNyumu wants to merge 2 commits intoitalanta:mainfrom
Conversation
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.
For this PR, I refactored the budget UI components from an Observable-driven pattern to Angular Signals. I replaced constructor DI with inject(), converted the consumed Observables using toSignal(), moved derived logic into computed(), and replaced subscription handling with a single effect(). The child component was also updated to accept a Signal input and remove all RxJS subscription logic.
This modernization simplifies state flow, removes memory-leak risks, and enables fine-grained UI updates.
The benefit of using signals is:
The difference in the coding styles is RxJS uses a stream-based approach focused on composing asynchronous event sequences with operators like map, switchMap, combineLatest, etc while signals use a state-based approach where each piece of data is a reactive value (signal, computed, effect) that updates synchronously.
Observables emit many values over time and require a subscription to start producing values. Signals hold a single value, update synchronously, and automatically notify dependent computations. Observables remain ideal for API streams and asynchronous workflows. Signals are better suited for component/UI state.
From mobile development, I’ve worked extensively with Kotlin Flow / StateFlow in Jetpack Compose and Flutter’s reactive state tools like mutableStateOf and Provider. These follow a declarative UI model where the UI reacts automatically to state changes. Angular Signals feel very similar to mutableStateOf in Compose. Compared to Flow or BLoC, Signals provide a lighter mental model for component-level state and reduce the overhead of managing async streams for simple UI rendering.