This document contains a detailed list of changes between RxJS 6.x and RxJS 7.x, presented in the order they can be found when diffing the TypeScript APIs in various module files.
_subscribe
method is no longerpublic
and is nowprotected
.- no longer has its own implementation of the
error
method inherited fromSubject
.
_subscribe
method is no longerpublic
and is nowprotected
.value
property is a getterget value()
instead ofreadonly value
, and can no longer be forcibly set.
- Generic signatures have changed. Do not explicitly pass generics.
- Generic signatures have changed. Do not explicitly pass generics.
- Generic signatures have changed. Do not explicitly pass generics.
_isComplete
is no longer a property._subscribe
method is no longerpublic
and is nowprotected
.
- Generic argument no longer extends
void
.
- Generic signatures have changed. Do not explicitly pass generics.
- No longer publicly exposes
_subscribe
key
properly isreadonly
.- No longer publicly exposes
constructor
.
- Generic signatures have changed. Do not explicitly pass generics.
- No longer has a generic and returns
Observable<unknown>
, you must cast the result.
- Generic signatures have changed. Do not explicitly pass generics.
- The
error
property is nowreadonly
. - The
hasValue
property is nowreadonly
. - The
kind
property is nowreadonly
. - The
value
property is nowreadonly
and may beundefined
. constructor
signature now only allows valid construction. For examplenew Notification('C', 'some_value')
will be an error in TypeScript.
_isScalar
property removed._subscribe
method is no longerpublic
and is now marked@internal
._trySubscribe
method is no longerpublic
and is now@internal
.pipe
method calls with9
or more arguments will now returnObservable<unknown>
rather thanObservable<{}>
.toPromise
method now correctly returnsPromise<T | undefined>
instead ofPromise<T>
. This a correction without a runtime change, because if the observable does not emit a value before completion, the promise will resolve withundefined
.static if
andstatic throw
properties are no longer defined. They were unused in version 6.lift
,source
, andoperator
properties are still deprecated, and should not be used. They are implementation details, and will very likely be renamed or missing in version 8.
- Generic signatures have changed. Do not explicitly pass generics.
- Generic signatures have changed. Do not explicitly pass generics.
- Generic signatures have changed. Do not explicitly pass generics.
- Generic signatures have changed. Do not explicitly pass generics.
- Calls with
9
or more arguments will now return(arg: A) => unknown
rather than(arg: A) => {}
.
- Generic signatures have changed. Do not explicitly pass generics.
_getNow
method has been removed._subscribe
method is no longerpublic
and is nowprotected
.
subscribe
will acceptPartial<Observer<T>>
now. All overloads with functions as arguments have been removed. This is becauseSubscribable
is intended to map to the basic observable contract from the TC39 proposal and the the return type of a call to[Symbol.observable]()
.
- See notes on
Subscribable
above.
destination
property must now be aSubscriber
or fullObserver
.syncErrorThrowable
property has been removed.syncErrorThrown
property has been removed.syncErrorValue
property has been removed._unsubscribeAndRecycle
method has been removed.
_parentOrParents
property has been removed.add
method returnsvoid
and no longer returns aSubscription
. ReturningSubscription
was an old behavior from the early days of version 5. If you add a function to a subscription (i.e.subscription.add(fn)
), you can remove that function directly by callingremove
with the same function instance. (i.e.subscription.remove(fn)
). Previously, you needed to get the returnedSubscription
object and pass that toremove
. In version 6 and lower, theSubscription
returned by callingadd
with anotherSubscription
was always the same subscription you passed in. (meaningsubscription.add(subs1).add(subs2)
was an antipattern and the same assubscription.add(subs1); subs1.add(subs2);
.
- The static
sortActions
method has been removed.
- Generic signatures have changed. Do not explicitly pass generics.
- A new method for creating a stream of animation frames. Each event will carry with it a high-resolution timestamp, and an ellapsed time since observation was started.
- A handler for dealing with errors that make it all the way down to the "end" of the observation chain when there is no error handler in the observer. Useful for doing things like logging unhandled errors in RxJS observable chains.
- A handler for edge cases where a subscriber within RxJS is notified after it has already "stopped", that is, a point in time where it has received an error or complete, but hasn't yet finalized. This is mostly useful for logging purposes.
- In RxJS 6, a little used feature allowed users to access the
subscriber
directly asthis
within a call to thenext
handler. The problem with this is it incurred heavy performance penalties. That behavior has been changed (because it wasn't really documented and it was barely ever used) to not change thethis
context of any user-provided subscription handlers. If you need to get that feature back, you can switch it on with this flag. Note this behavior will be removed completely in version 8.
- This is the new means for creating a
ConnectableObservable
, and really us a replacement for non-selector usage ofmulticast
andpublish
variants. Simply pass your source observable toconnectable
with theSubject
you'd like to connect through.
- A better, more tree-shakable replacement for
toPromise()
(which is now deprecated). This function allows the user to convert anyObservable
in to aPromise
that will resolve when the source observable emits its firsr value. If the source observable closes without emitting a value, the returned promise will reject with anEmptyError
, or it will resolve with a configureddefaultValue
.
- This is just a type, but it's important. This type defines the allowed types that can be passed to almost every API within RxJS that accepts an Observable. It has always accepted
Observable
,Promise
,Iterable
, andArrayLike
. Now it will also acceptAsyncIterable
andReadableStream
.
AsyncIterables
such as those defined byIxJS
or by async generators (async function*
), may now be passed to any API that accepts an observable, and can be converted to anObservable
directly usingfrom
.
ReadableStream
such as those returned byfetch
, et al, can be passed to any API that accepts an observable, and can be converted toObservable
directly usingfrom
.
- A bug was fixed that prevented a completed or errored
ReplaySubject
from accumulating values in its buffer when resubscribed to another source. This breaks some uses - like this StackOverflow answer - that depended upon the buggy behavior.
- Now allows adding and removing of functions directly via
add
andremove
methods.
- Now accepts an
errorFactory
of() => any
to defer the creation of the error until the time it will be emitted. It is recommended to use this method, as Errors created in most popular JavaScript runtimes will retain all values in the current scope for debugging purposes.
- The observable returned by the
audit
operator's duration selector must emit a next notification to end the duration. Complete notifications no longer end the duration.
buffer
now subscribes to the source observable before it subscribes to the closing notifier. Previously, it subscribed to the closing notifier first.
- The observable returned by the
bufferToggle
operator's closing selector must emit a next notification to close the buffer. Complete notifications no longer close the buffer.
- The observable returned by the
bufferWhen
operator's closing selector must emit a next notification to close the buffer. Complete notifications no longer close the buffer.
- Generic signatures have changed. Do not explicitly pass generics.
- Generic signatures have changed. Do not explicitly pass generics.
- Still deprecated, use the new
concatWith
.
- Generic signatures have changed. Do not explicitly pass generics.
- Generic signatures have changed. Do not explicitly pass generics.
- The observable returned by the
debounce
operator's duration selector must emit a next notification to end the duration. Complete notifications no longer end the duration.
- Generic signatures have changed. Do not explicitly pass generics.
delayWhen
will no longer emit if the duration selector simply completes without a value. Notifiers must notify with a value, not a completion.
- Generic signatures have changed. Do not explicitly pass generics.
- Generic signatures have changed. Do not explicitly pass generics.
- Generic signatures have changed. Do not explicitly pass generics.
- Still deprecated, use the new
mergeWith
.
- Generic signatures have changed. Do not explicitly pass generics.
- Generic signatures have changed. Do not explicitly pass generics.
- Generic signatures have changed. Do not explicitly pass generics.
- Generic signatures have changed. Do not explicitly pass generics.
- The
sample
operator's notifier observable must emit a next notification to effect a sample. Complete notifications no longer effect a sample.
- Generic signatures have changed. Do not explicitly pass generics.
- Generic signatures have changed. Do not explicitly pass generics.
- Generic signatures have changed. Do not explicitly pass generics.
- Generic signatures have changed. Do not explicitly pass generics.
- The observable returned by the
throttle
operator's duration selector must emit a next notification to end the duration. Complete notifications no longer end the duration.
- The observable returned by the
windowToggle
operator's closing selector must emit a next notification to close the window. Complete notifications no longer close the window.
- Generic signatures have changed. Do not explicitly pass generics.
- Generic signatures have changed. Do not explicitly pass generics.
- Still deprecated, use the new
zipWith
.
- New operator to cover the use cases of
publish
variants that use aselector
. Wherein the selector allows the user to define multicast behavior prior to connection to the source observable for the multicast.
- Added functionality to allow complete configuration of what type of
Subject
is used to multicast, and when that subject is reset.
- Added more configuration options to
timeout
, so it could be used to timeout just if the first item doesn't arrive quickly enough, or it could be used as a timeout between each item. Users may also pass aDate
object to define an absolute time for a timeout for the first time to arrive. Adds additional information to the timeout error, and the ability to pass along metadata with the timeout for identification purposes.
- Simply renamed versions of the operators
zip
,concat
,mergeWith
, andrace
. So we can deprecate those old names and use the new names without collisions.
AjaxRequest
is no longer used to type the configuration argument for calls toajax
. The new type isAjaxConfig
. This was done to disambiguate two very similar types with different use cases.AjaxRequest
is still there, but properties have changed, and it is used to show what final request information was send as part of an event response.
- Now includes
responseHeaders
. - Now includes event
type
andtotal
numbers for examinining upload and download progress (seeincludeUploadProgess
andincludeDownloadProgress
).
- A flag to make a request that will include streaming upload progress events in the returned observable.
- A flag to make a request that will include streaming upload progress events in the returned observable.
- Configuration for setting query parameters in the URL of the request to be made.
xsrfCookieName
andxsrfHeaderName
were added for cross-site request forgery prevention capabilities.
No changes.
- A new means of comparing the equality of to observables. If all emissions are the same, and at the same time, then they are equal. This is primarily useful for refactoring operator chains and making sure that they are equivalent.