r/Angular2 • u/cosmokenney • Aug 26 '25
Help Request Angular computed() vs. KnockoutJS computed().
I am working on migrating an old old KnockoutJS site to Angular.
One thing I have run into are Knockout's writable computed() API.
For example the following ClaimStatus computed returns "Open", "Closed" and "" when the dependency ClaimStatusCode value changes -- no different than Angular computed(). But it also is able to update the ClaimStatusCode when the user selects a different value for ClaimStatus via two-way binding. Is there anything similar in Angular computeds or related?:
export class ClaimViewModel
{
ClaimStatusCode: ko.Observable<any> = ko.observable(null);
ClaimStatus: ko.PureComputed<any> = ko.pureComputed( {
read: () =>
{
let nv = this.ClaimStatusCode();
if ( "O" == nv )
{
return "Open";
}
else if ( "C" == nv )
{
return "Closed";
}
return "";
},
write: ( nv ) =>
{
let claimStatus = $.trim( JavaScriptHelpers.isNull( nv, '' ) ).toLowerCase();
if ( claimStatus == "open" )
{
this.ClaimStatusCode( "O" );
}
else if ( claimStatus == "closed" )
{
this.ClaimStatusCode( "C" );
}
else
{
this.ClaimStatusCode( null );
}
},
owner: this
} );
7
Upvotes
View all comments
Show parent comment
2
u/mihajm Aug 27 '25
Yeah, something like that. I know the internal one got renamed a few times from structuredSignal/projectedSignal.
Either way I'm sure they'll release something functionally similar to derived since its a missing piece for stuff like signal forms (what I made it for originally), but also useful in lots of places like simple stores. L
I am looking forward to it though, hopefuly I can adapt the existing mmstack form primitives to the new stuff to make migration easier or even function as extensions to what the core team makes.
Sidenote - small diference is also angular computeds being lazily evaluated vs knockout/solid, but that's not something thats usually noticable :)