You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I am currently upgrading my app to use Angulars new signal api. WritableSignal is working as expected. However computed signals seem to be not working correctly. My computed signals are initialised correctly but are not update if the referenced WritableSignal is updated with .set() or .update(()=>{}) functions. If I convert the WritabelSignal with toObservable() (my current workaorund) things are working as expected.
I am also observing that WritableSignal changes to not always lead to rerendering of the component. When changing the WritableSignal Value in the observable subscription as shown below, I have to call ChangeDetectorRef.detectChanges() to update the ui.
To Reproduce
Here is an example computed signal:
public _onSubMenuPage = computed(() => this.navSrv._currentRoute().startsWith('/sub-menu('));
This references:
public _currentRoute = signal('');
which I tried to update with .set() and .update() methods
Expected behavior
I expected the computed signal to be updated when its value changes to a different value than the current one.
Sample project
Additional context
When I convert the WritableSignal to an observable and subscribe to it, I get notfied through changes. This can be considered as a workaround as long as the computed methods is not working.
Update: The issue might be related to the fact that I am using the signals in components that reside in different PageRouterOutlets. I can use an effect(()=>void) to update component state but than have to call ChangeDetectorRef.detectChanges() in order for the changes to get rendered.
The text was updated successfully, but these errors were encountered:
Environment
Dependencies
Describe the bug
I am currently upgrading my app to use Angulars new signal api. WritableSignal is working as expected. However computed signals seem to be not working correctly. My computed signals are initialised correctly but are not update if the referenced WritableSignal is updated with .set() or .update(()=>{}) functions. If I convert the WritabelSignal with toObservable() (my current workaorund) things are working as expected.
I am also observing that WritableSignal changes to not always lead to rerendering of the component. When changing the WritableSignal Value in the observable subscription as shown below, I have to call ChangeDetectorRef.detectChanges() to update the ui.
To Reproduce
Here is an example computed signal:
public _onSubMenuPage = computed(() => this.navSrv._currentRoute().startsWith('/sub-menu('));
This references:
public _currentRoute = signal('');
which I tried to update with .set() and .update() methods
Expected behavior
I expected the computed signal to be updated when its value changes to a different value than the current one.
Sample project
Additional context
When I convert the WritableSignal to an observable and subscribe to it, I get notfied through changes. This can be considered as a workaround as long as the computed methods is not working.
this._currentRoute$ = toObservable(this.navSrv._currentRoute);
Update: The issue might be related to the fact that I am using the signals in components that reside in different PageRouterOutlets. I can use an effect(()=>void) to update component state but than have to call ChangeDetectorRef.detectChanges() in order for the changes to get rendered.
The text was updated successfully, but these errors were encountered: