| 1 |
import { Subscriber } from './Subscriber'; |
| 2 |
import { ObservableNotification } from './types'; |
| 3 |
|
| 4 |
/** |
| 5 |
* The {@link GlobalConfig} object for RxJS. It is used to configure things |
| 6 |
* like how to react on unhandled errors. |
| 7 |
*/ |
| 8 |
export const config: GlobalConfig = { |
| 9 |
onUnhandledError: null, |
| 10 |
onStoppedNotification: null, |
| 11 |
Promise: undefined, |
| 12 |
useDeprecatedSynchronousErrorHandling: false, |
| 13 |
useDeprecatedNextContext: false, |
| 14 |
}; |
| 15 |
|
| 16 |
/** |
| 17 |
* The global configuration object for RxJS, used to configure things |
| 18 |
* like how to react on unhandled errors. Accessible via {@link config} |
| 19 |
* object. |
| 20 |
*/ |
| 21 |
export interface GlobalConfig { |
| 22 |
/** |
| 23 |
* A registration point for unhandled errors from RxJS. These are errors that |
| 24 |
* cannot were not handled by consuming code in the usual subscription path. For |
| 25 |
* example, if you have this configured, and you subscribe to an observable without |
| 26 |
* providing an error handler, errors from that subscription will end up here. This |
| 27 |
* will _always_ be called asynchronously on another job in the runtime. This is because |
| 28 |
* we do not want errors thrown in this user-configured handler to interfere with the |
| 29 |
* behavior of the library. |
| 30 |
*/ |
| 31 |
onUnhandledError: ((err: any) => void) | null; |
| 32 |
|
| 33 |
/** |
| 34 |
* A registration point for notifications that cannot be sent to subscribers because they |
| 35 |
* have completed, errored or have been explicitly unsubscribed. By default, next, complete |
| 36 |
* and error notifications sent to stopped subscribers are noops. However, sometimes callers |
| 37 |
* might want a different behavior. For example, with sources that attempt to report errors |
| 38 |
* to stopped subscribers, a caller can configure RxJS to throw an unhandled error instead. |
| 39 |
* This will _always_ be called asynchronously on another job in the runtime. This is because |
| 40 |
* we do not want errors thrown in this user-configured handler to interfere with the |
| 41 |
* behavior of the library. |
| 42 |
*/ |
| 43 |
onStoppedNotification: ((notification: ObservableNotification<any>, subscriber: Subscriber<any>) => void) | null; |
| 44 |
|
| 45 |
/** |
| 46 |
* The promise constructor used by default for {@link Observable#toPromise toPromise} and {@link Observable#forEach forEach} |
| 47 |
* methods. |
| 48 |
* |
| 49 |
* @deprecated As of version 8, RxJS will no longer support this sort of injection of a |
| 50 |
* Promise constructor. If you need a Promise implementation other than native promises, |
| 51 |
* please polyfill/patch Promise as you see appropriate. Will be removed in v8. |
| 52 |
*/ |
| 53 |
Promise?: PromiseConstructorLike; |
| 54 |
|
| 55 |
/** |
| 56 |
* If true, turns on synchronous error rethrowing, which is a deprecated behavior |
| 57 |
* in v6 and higher. This behavior enables bad patterns like wrapping a subscribe |
| 58 |
* call in a try/catch block. It also enables producer interference, a nasty bug |
| 59 |
* where a multicast can be broken for all observers by a downstream consumer with |
| 60 |
* an unhandled error. DO NOT USE THIS FLAG UNLESS IT'S NEEDED TO BUY TIME |
| 61 |
* FOR MIGRATION REASONS. |
| 62 |
* |
| 63 |
* @deprecated As of version 8, RxJS will no longer support synchronous throwing |
| 64 |
* of unhandled errors. All errors will be thrown on a separate call stack to prevent bad |
| 65 |
* behaviors described above. Will be removed in v8. |
| 66 |
*/ |
| 67 |
useDeprecatedSynchronousErrorHandling: boolean; |
| 68 |
|
| 69 |
/** |
| 70 |
* If true, enables an as-of-yet undocumented feature from v5: The ability to access |
| 71 |
* `unsubscribe()` via `this` context in `next` functions created in observers passed |
| 72 |
* to `subscribe`. |
| 73 |
* |
| 74 |
* This is being removed because the performance was severely problematic, and it could also cause |
| 75 |
* issues when types other than POJOs are passed to subscribe as subscribers, as they will likely have |
| 76 |
* their `this` context overwritten. |
| 77 |
* |
| 78 |
* @deprecated As of version 8, RxJS will no longer support altering the |
| 79 |
* context of next functions provided as part of an observer to Subscribe. Instead, |
| 80 |
* you will have access to a subscription or a signal or token that will allow you to do things like |
| 81 |
* unsubscribe and test closed status. Will be removed in v8. |
| 82 |
*/ |
| 83 |
useDeprecatedNextContext: boolean; |
| 84 |
} |