1
- import { Observable } from '../Observable' ;
2
1
import { innerFrom } from '../observable/innerFrom' ;
3
2
import { Subject } from '../Subject' ;
4
3
import { SafeSubscriber } from '../Subscriber' ;
5
4
import { Subscription } from '../Subscription' ;
6
- import { MonoTypeOperatorFunction , SubjectLike } from '../types' ;
5
+ import { MonoTypeOperatorFunction , SubjectLike , ObservableInput } from '../types' ;
7
6
import { operate } from '../util/lift' ;
8
7
9
8
export interface ShareConfig < T > {
@@ -13,37 +12,37 @@ export interface ShareConfig<T> {
13
12
*/
14
13
connector ?: ( ) => SubjectLike < T > ;
15
14
/**
16
- * If true, the resulting observable will reset internal state on error from source and return to a "cold" state. This
15
+ * If ` true` , the resulting observable will reset internal state on error from source and return to a "cold" state. This
17
16
* allows the resulting observable to be "retried" in the event of an error.
18
- * If false, when an error comes from the source it will push the error into the connecting subject, and the subject
17
+ * If ` false` , when an error comes from the source it will push the error into the connecting subject, and the subject
19
18
* will remain the connecting subject, meaning the resulting observable will not go "cold" again, and subsequent retries
20
19
* or resubscriptions will resubscribe to that same subject. In all cases, RxJS subjects will emit the same error again, however
21
20
* {@link ReplaySubject} will also push its buffered values before pushing the error.
22
- * It is also possible to pass a notifier factory returning an observable instead which grants more fine-grained
21
+ * It is also possible to pass a notifier factory returning an `ObservableInput` instead which grants more fine-grained
23
22
* control over how and when the reset should happen. This allows behaviors like conditional or delayed resets.
24
23
*/
25
- resetOnError ?: boolean | ( ( error : any ) => Observable < any > ) ;
24
+ resetOnError ?: boolean | ( ( error : any ) => ObservableInput < any > ) ;
26
25
/**
27
- * If true, the resulting observable will reset internal state on completion from source and return to a "cold" state. This
26
+ * If ` true` , the resulting observable will reset internal state on completion from source and return to a "cold" state. This
28
27
* allows the resulting observable to be "repeated" after it is done.
29
- * If false, when the source completes, it will push the completion through the connecting subject, and the subject
28
+ * If ` false` , when the source completes, it will push the completion through the connecting subject, and the subject
30
29
* will remain the connecting subject, meaning the resulting observable will not go "cold" again, and subsequent repeats
31
30
* or resubscriptions will resubscribe to that same subject.
32
- * It is also possible to pass a notifier factory returning an observable instead which grants more fine-grained
31
+ * It is also possible to pass a notifier factory returning an `ObservableInput` instead which grants more fine-grained
33
32
* control over how and when the reset should happen. This allows behaviors like conditional or delayed resets.
34
33
*/
35
- resetOnComplete ?: boolean | ( ( ) => Observable < any > ) ;
34
+ resetOnComplete ?: boolean | ( ( ) => ObservableInput < any > ) ;
36
35
/**
37
- * If true, when the number of subscribers to the resulting observable reaches zero due to those subscribers unsubscribing, the
36
+ * If ` true` , when the number of subscribers to the resulting observable reaches zero due to those subscribers unsubscribing, the
38
37
* internal state will be reset and the resulting observable will return to a "cold" state. This means that the next
39
38
* time the resulting observable is subscribed to, a new subject will be created and the source will be subscribed to
40
39
* again.
41
- * If false, when the number of subscribers to the resulting observable reaches zero due to unsubscription, the subject
40
+ * If ` false` , when the number of subscribers to the resulting observable reaches zero due to unsubscription, the subject
42
41
* will remain connected to the source, and new subscriptions to the result will be connected through that same subject.
43
- * It is also possible to pass a notifier factory returning an observable instead which grants more fine-grained
42
+ * It is also possible to pass a notifier factory returning an `ObservableInput` instead which grants more fine-grained
44
43
* control over how and when the reset should happen. This allows behaviors like conditional or delayed resets.
45
44
*/
46
- resetOnRefCountZero ?: boolean | ( ( ) => Observable < any > ) ;
45
+ resetOnRefCountZero ?: boolean | ( ( ) => ObservableInput < any > ) ;
47
46
}
48
47
49
48
export function share < T > ( ) : MonoTypeOperatorFunction < T > ;
@@ -245,7 +244,7 @@ export function share<T>(options: ShareConfig<T> = {}): MonoTypeOperatorFunction
245
244
246
245
function handleReset < T extends unknown [ ] = never [ ] > (
247
246
reset : ( ) => void ,
248
- on : boolean | ( ( ...args : T ) => Observable < any > ) ,
247
+ on : boolean | ( ( ...args : T ) => ObservableInput < any > ) ,
249
248
...args : T
250
249
) : Subscription | undefined {
251
250
if ( on === true ) {
@@ -264,5 +263,5 @@ function handleReset<T extends unknown[] = never[]>(
264
263
} ,
265
264
} ) ;
266
265
267
- return on ( ...args ) . subscribe ( onSubscriber ) ;
266
+ return innerFrom ( on ( ...args ) ) . subscribe ( onSubscriber ) ;
268
267
}
0 commit comments