now in the old Angular code we were using
@Input() foo = '';
ngOnChanges(changes: Record<string, SimpleChange | undefined>): void {
if (changes['foo']) {
if (changes['foo'].firstChange) {
// some logic for first change
console.log('first change', changes['foo'].currentValue);
} else {
// another logic for 2+ changes
console.log(
'2+ changes',
changes['foo'].previousValue,
changes['foo'].currentValue
);
}
}
}
how to achieve the same behavior using the new signal input and effect?
I have read that I can convert the signal to observable and use pairwise, but pairwise doesn't emit for first value at all
here is simple example to try it out https://stackblitz.com/edit/stackblitz-starters-ymnhaw?file=src%2Fcmp%2Fcmp.component.ts
why I'm asking this question? because in the RFC for signal components, it's mentioned that
- Signal-based components will retain the following lifecycle methods
ngOnInitandngOnDestroyonly ngOnChanges- is used to observe changes to inputs. As inputs are signal-based, computed can be used to derive new values, or effect to react side-effectfully.

pairwisemaybe you could usemapand convert to an object with afirstChangeproperty:map((value, i) => ({ value, firstChange: i === 0 }))StackBlitz