File tree 1 file changed +11
-6
lines changed
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export class Engine implements EngineInterface {
16
16
private reads : Array < Function > = [ ] ;
17
17
private work : Array < Function > = [ ] ;
18
18
private running : Boolean = false ;
19
+ private skipCounter : number = 4 ;
19
20
scheduleRead ( callback : Function ) {
20
21
this . reads . unshift ( callback ) ;
21
22
this . run ( ) ;
@@ -28,14 +29,18 @@ export class Engine implements EngineInterface {
28
29
if ( ! this . running ) {
29
30
this . running = true ;
30
31
W . rAF ( ( ) => {
31
- this . running = false ;
32
- for ( let i = 0 , rlen = this . reads . length ; i < rlen ; i ++ ) {
33
- this . reads . pop ( ) ( ) ;
34
- }
35
- for ( let i = 0 , wlen = this . work . length ; i < wlen ; i ++ ) {
36
- this . work . pop ( ) ( ) ;
32
+ if ( this . skipCounter > 3 ) {
33
+ this . skipCounter = 0 ;
34
+ for ( let i = 0 , rlen = this . reads . length ; i < rlen ; i ++ ) {
35
+ this . reads . pop ( ) ( ) ;
36
+ }
37
+ for ( let i = 0 , wlen = this . work . length ; i < wlen ; i ++ ) {
38
+ this . work . pop ( ) ( ) ;
39
+ }
37
40
}
41
+ this . skipCounter ++ ;
38
42
if ( this . work . length > 0 || this . reads . length > 0 ) {
43
+ this . running = false ;
39
44
this . run ( ) ;
40
45
}
41
46
} ) ;
You can’t perform that action at this time.
0 commit comments