I updated rxjs from version 6.x.x to 7.x.x, but following error appeared:
Error in src/app/app.component.ts (12:19) Expected 1 arguments, but got 0.
when trying to next
an empty value to the Subject
destroy$ = new Subject();
constructor() {
this.destroy$.next(); // <-- Expected 1 arguments, but got 0.
}
Error stackblitz
tl;dr:
Either typecast it with void
:
new Subject<void>();
or pass a fake value:
this.destroy$.next(true);
Rxjs 7 changes
After checking the changelog and several github issues about this situation,
Subject: resolve issue where Subject constructor errantly allowed an argument (#5476) (e1d35dc)
Subject: no default generic (e678e81)
Changelog 7.0.0-beta.1 and the commit where empty value is removed from the tests
I realized that the solution was to either provide a value or simply typecast the Subject
with <void>
as in destroy$ = new Subject<void>()
if you want to next
it with an empty value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With