1+ import searchTimer from './backburner/binary-search' ;
2+ import DeferredActionQueues from './backburner/deferred-action-queues' ;
3+ import Evented from './backburner/evented' ;
4+ import iteratorDrain , { Iteratable } from './backburner/iterator-drain' ;
5+ import Queue , { QUEUE_STATE } from './backburner/queue' ;
16import {
27 findItem ,
38 findTimer ,
49 getOnError ,
510 isCoercableNumber
611} from './backburner/utils' ;
712
8- import searchTimer from './backburner/binary-search' ;
9- import DeferredActionQueues from './backburner/deferred-action-queues' ;
10- import iteratorDrain , { Iteratable } from './backburner/iterator-drain' ;
11-
12- import Queue , { QUEUE_STATE } from './backburner/queue' ;
13-
1413type Timer = any ;
1514
1615const noop = function ( ) { } ;
@@ -45,7 +44,7 @@ function parseArgs() {
4544
4645let UUID = 0 ;
4746
48- export default class Backburner {
47+ export default class Backburner extends Evented {
4948 public static Queue = Queue ;
5049
5150 public DEBUG = false ;
@@ -60,13 +59,6 @@ export default class Backburner {
6059 private instanceStack : DeferredActionQueues [ ] = [ ] ;
6160 private _debouncees : any [ ] = [ ] ;
6261 private _throttlers : any [ ] = [ ] ;
63- private _eventCallbacks : {
64- end : Function [ ] ;
65- begin : Function [ ] ;
66- } = {
67- end : [ ] ,
68- begin : [ ]
69- } ;
7062
7163 private _timerTimeoutId : number | null = null ;
7264 private _timers : any [ ] = [ ] ;
@@ -83,7 +75,8 @@ export default class Backburner {
8375 private _autorun : number | null = null ;
8476 private _boundAutorunEnd : ( ) => void ;
8577
86- constructor ( queueNames : string [ ] , options : any = { } ) {
78+ constructor ( queueNames : string [ ] , options : any = { } ) {
79+ super ( ) ;
8780 this . queueNames = queueNames ;
8881 this . options = options ;
8982 if ( ! this . options . defaultQueue ) {
@@ -172,38 +165,6 @@ export default class Backburner {
172165 }
173166 }
174167
175- public on ( eventName , callback ) {
176- if ( typeof callback !== 'function' ) {
177- throw new TypeError ( `Callback must be a function` ) ;
178- }
179- let callbacks = this . _eventCallbacks [ eventName ] ;
180- if ( callbacks !== undefined ) {
181- callbacks . push ( callback ) ;
182- } else {
183- throw new TypeError ( `Cannot on() event ${ eventName } because it does not exist` ) ;
184- }
185- }
186-
187- public off ( eventName , callback ) {
188- let callbacks = this . _eventCallbacks [ eventName ] ;
189- if ( ! eventName || callbacks === undefined ) {
190- throw new TypeError ( `Cannot off() event ${ eventName } because it does not exist` ) ;
191- }
192- let callbackFound = false ;
193- if ( callback ) {
194- for ( let i = 0 ; i < callbacks . length ; i ++ ) {
195- if ( callbacks [ i ] === callback ) {
196- callbackFound = true ;
197- callbacks . splice ( i , 1 ) ;
198- i -- ;
199- }
200- }
201- }
202- if ( ! callbackFound ) {
203- throw new TypeError ( `Cannot off() callback that does not exist` ) ;
204- }
205- }
206-
207168 public run ( target : Function ) ;
208169 public run ( target : Function | any | null , method ?: Function | string , ...args ) ;
209170 public run ( target : any | null | undefined , method ?: Function , ...args : any [ ] ) ;
@@ -614,27 +575,6 @@ export default class Backburner {
614575 return false ;
615576 }
616577
617- /**
618- Trigger an event. Supports up to two arguments. Designed around
619- triggering transition events from one run loop instance to the
620- next, which requires an argument for the first instance and then
621- an argument for the next instance.
622-
623- @private
624- @method _trigger
625- @param {String } eventName
626- @param {any } arg1
627- @param {any } arg2
628- */
629- private _trigger < T , U > ( eventName : string , arg1 : T , arg2 : U ) {
630- let callbacks = this . _eventCallbacks [ eventName ] ;
631- if ( callbacks !== undefined ) {
632- for ( let i = 0 ; i < callbacks . length ; i ++ ) {
633- callbacks [ i ] ( arg1 , arg2 ) ;
634- }
635- }
636- }
637-
638578 private _runExpiredTimers ( ) {
639579 this . _timerTimeoutId = null ;
640580 if ( this . _timers . length > 0 ) {
0 commit comments