File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed
packages/core/src/operators Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { TestScheduler } from "rxjs/testing"
2
- import { from } from "rxjs"
2
+ import { from , merge , defer } from "rxjs"
3
3
import { shareLatest } from "../"
4
+ import { withLatestFrom , startWith , map } from "rxjs/operators"
4
5
5
6
const scheduler = ( ) =>
6
7
new TestScheduler ( ( actual , expected ) => {
@@ -49,6 +50,29 @@ describe("shareLatest", () => {
49
50
} )
50
51
} )
51
52
53
+ // prettier-ignore
54
+ it ( "should be able to handle recursively synchronous subscriptions" , ( ) => {
55
+ scheduler ( ) . run ( ( { expectObservable, hot } ) => {
56
+ const values$ = hot ( '----b-c-d---' )
57
+ const latest$ = hot ( '----------x-' )
58
+ const expected = ' a---b-c-d-d-'
59
+ const input$ = merge (
60
+ values$ ,
61
+ latest$ . pipe (
62
+ withLatestFrom ( defer ( ( ) => result$ ) ) ,
63
+ map ( ( [ , latest ] ) => latest )
64
+ )
65
+ )
66
+
67
+ const result$ = input$ . pipe (
68
+ startWith ( 'a' ) ,
69
+ shareLatest ( )
70
+ )
71
+
72
+ expectObservable ( result$ , '^' ) . toBe ( expected )
73
+ } )
74
+ } )
75
+
52
76
// prettier-ignore
53
77
it ( "should not skip values on a sync source" , ( ) => {
54
78
scheduler ( ) . run ( ( { expectObservable } ) => {
You can’t perform that action at this time.
0 commit comments