File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ const { Flow } = self . yozo ;
2
+ const flow = new Flow ( ) ;
3
+ let resolve
4
+ const promise = new Promise ( ( ...args ) => resolve = args [ 0 ] )
5
+ let stopped = false
6
+ flow . once ( )
7
+ . await ( ( ) => promise )
8
+ . cleanup ( ( ) => stopped = true )
9
+
10
+ flow . now ( ) ;
11
+ await 'microtask'
12
+ flow . now ( ) ;
13
+ assert ( ! stopped ) ;
14
+
15
+ resolve ( )
16
+ await 'microtask'
17
+ assert ( stopped ) ;
Original file line number Diff line number Diff line change
1
+ const { Flow } = self . yozo ;
2
+ const flow = new Flow ( ) ;
3
+ let first = 0
4
+ let second = 0
5
+ let stopped = false
6
+ flow . await ( ( ) => 'microtask' )
7
+ . then ( ( ) => first ++ )
8
+ . await ( ( ) => 'microtask' )
9
+ . then ( ( ) => second ++ )
10
+ . once ( )
11
+ . cleanup ( ( ) => stopped = true )
12
+
13
+ flow . now ( )
14
+ await 'microtask'
15
+ flow . now ( )
16
+
17
+ assert ( first == 1 )
18
+ assert ( second == 0 )
19
+ assert ( ! stopped )
20
+
21
+ await 'microtask'
22
+ assert ( first == 1 )
23
+ assert ( second == 1 )
24
+ assert ( stopped )
Original file line number Diff line number Diff line change
1
+ const { Flow } = self . yozo ;
2
+ const flow = new Flow ( ) ;
3
+
4
+ assert ( flow . once ( ) == flow ) ;
5
+
6
+ flow . stop ( ) ;
You can’t perform that action at this time.
0 commit comments