1
1
import { Subscriber } from './Subscriber' ;
2
2
import { ObservableNotification } from './types' ;
3
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
+
4
16
/**
5
17
* The global configuration object for RxJS, used to configure things
6
- * like what Promise constructor should used to create Promises
18
+ * like how to react on unhandled errors. Accessible via {@link config}
19
+ * object.
7
20
*/
8
- export const config = {
21
+ export interface GlobalConfig {
9
22
/**
10
23
* A registration point for unhandled errors from RxJS. These are errors that
11
24
* cannot were not handled by consuming code in the usual subscription path. For
@@ -15,7 +28,7 @@ export const config = {
15
28
* we do not want errors thrown in this user-configured handler to interfere with the
16
29
* behavior of the library.
17
30
*/
18
- onUnhandledError : null as ( ( err : any ) => void ) | null ,
31
+ onUnhandledError : ( ( err : any ) => void ) | null ;
19
32
20
33
/**
21
34
* A registration point for notifications that cannot be sent to subscribers because they
@@ -27,17 +40,17 @@ export const config = {
27
40
* we do not want errors thrown in this user-configured handler to interfere with the
28
41
* behavior of the library.
29
42
*/
30
- onStoppedNotification : null as ( ( notification : ObservableNotification < any > , subscriber : Subscriber < any > ) => void ) | null ,
43
+ onStoppedNotification : ( ( notification : ObservableNotification < any > , subscriber : Subscriber < any > ) => void ) | null ;
31
44
32
45
/**
33
- * The promise constructor used by default for methods such as
34
- * { @link toPromise} and { @link forEach}
46
+ * The promise constructor used by default for { @link toPromise} and { @link forEach}
47
+ * methods.
35
48
*
36
49
* @deprecated As of version 8, RxJS will no longer support this sort of injection of a
37
50
* Promise constructor. If you need a Promise implementation other than native promises,
38
51
* please polyfill/patch Promise as you see appropriate. Will be removed in v8.
39
52
*/
40
- Promise : undefined as PromiseConstructorLike | undefined ,
53
+ Promise ?: PromiseConstructorLike ;
41
54
42
55
/**
43
56
* If true, turns on synchronous error rethrowing, which is a deprecated behavior
@@ -51,7 +64,7 @@ export const config = {
51
64
* of unhandled errors. All errors will be thrown on a separate call stack to prevent bad
52
65
* behaviors described above. Will be removed in v8.
53
66
*/
54
- useDeprecatedSynchronousErrorHandling : false ,
67
+ useDeprecatedSynchronousErrorHandling : boolean ;
55
68
56
69
/**
57
70
* If true, enables an as-of-yet undocumented feature from v5: The ability to access
@@ -67,5 +80,5 @@ export const config = {
67
80
* you will have access to a subscription or a signal or token that will allow you to do things like
68
81
* unsubscribe and test closed status. Will be removed in v8.
69
82
*/
70
- useDeprecatedNextContext : false ,
71
- } ;
83
+ useDeprecatedNextContext : boolean ;
84
+ }
0 commit comments