Open ShacharHarshuv opened 5 days ago
And convert .next
to .set
?
Yes, sorry. Added!
Hi, something is coming 🙌
Let's wait a little bit more 😬
Do you mean you are working on it, that Angular's core team is working on it, or that you think it's premature to add such a feature now?
I've been working on a prototype for myself to do these kinds of migration, but nothing ready yet.
Cool! I also thought that a next step could be converting something like that:
combineLatest({
a: toObservable(this.a),
b: toObservable(this.b),
})
.pipe(
map(({a, b}) => this.a() + this.b()),
distinctUntilChanged(), // ... and other operators that don't matter with signals like share etc
);
to
computed(() => this.a() + this.b());
Might be harder than I think but it feels like it could be possible.
In the spirit of writing migration scripts to modernize Angular code, I want to propose the following script. Let me know if you think this is something that could fit the library.
The assumption here that everything that a
BehaviorSubject
is used for, a signal can be used instead, and I think it is possible to write a (relatively) robust script to do that migration. The script will:new BehaviorSubject
withsignal
, while keeping any used generics / inferred types..next
with.set
$
myValue$.value
usages tomyValue()
myValue$
with `toObservable(myValue)myValue
as a signal andmyValue$
as a stream. In that case, if there is no$
as a postfix, we'll have to add it.