GlobalConfig

interface stable

The global configuration object for RxJS, used to configure things like how to react on unhandled errors. Accessible via config object.

interface GlobalConfig {
  onUnhandledError: ((err: any) => void) | null
  onStoppedNotification: ((notification: ObservableNotification<any>, subscriber: Subscriber<any>) => void) | null
  Promise?: PromiseConstructorLike
  useDeprecatedSynchronousErrorHandling: boolean
  useDeprecatedNextContext: boolean
}

Properties

Property Type Description
onUnhandledError ((err: any) => void) | null

A registration point for unhandled errors from RxJS. These are errors that cannot were not handled by consuming code in the usual subscription path. For example, if you have this configured, and you subscribe to an observable without providing an error handler, errors from that subscription will end up here. This will always be called asynchronously on another job in the runtime. This is because we do not want errors thrown in this user-configured handler to interfere with the behavior of the library.

onStoppedNotification ((notification: ObservableNotification<any>, subscriber: Subscriber<any>) => void) | null

A registration point for notifications that cannot be sent to subscribers because they have completed, errored or have been explicitly unsubscribed. By default, next, complete and error notifications sent to stopped subscribers are noops. However, sometimes callers might want a different behavior. For example, with sources that attempt to report errors to stopped subscribers, a caller can configure RxJS to throw an unhandled error instead. This will always be called asynchronously on another job in the runtime. This is because we do not want errors thrown in this user-configured handler to interfere with the behavior of the library.

Promise PromiseConstructorLike

The promise constructor used by default for toPromise and forEach methods.

useDeprecatedSynchronousErrorHandling boolean

If true, turns on synchronous error rethrowing, which is a deprecated behavior in v6 and higher. This behavior enables bad patterns like wrapping a subscribe call in a try/catch block. It also enables producer interference, a nasty bug where a multicast can be broken for all observers by a downstream consumer with an unhandled error. DO NOT USE THIS FLAG UNLESS IT'S NEEDED TO BUY TIME FOR MIGRATION REASONS.

useDeprecatedNextContext boolean

If true, enables an as-of-yet undocumented feature from v5: The ability to access unsubscribe() via this context in next functions created in observers passed to subscribe.

This is being removed because the performance was severely problematic, and it could also cause issues when types other than POJOs are passed to subscribe as subscribers, as they will likely have their this context overwritten.

© 2015–2021 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors.
Code licensed under an Apache-2.0 License. Documentation licensed under CC BY 4.0.
https://rxjs.dev/api/index/interface/GlobalConfig