SHARE
TWEET

Clousre in EventEmitter

sergeyampo Jun 2nd, 2020 (edited) 666 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     private handleSignals(
  2.         proc: NodeJS.Process,
  3.         signals: NodeJS.Signals[],
  4.         errorToCallbacks: Map<EProcessError | EProcessSignals, Array<() => void>>,
  5.     ): void {
  6.         let currCloseCbs: Array<() => void> = [() => {}];
  7.         for (const sig of signals) {
  8.             currCloseCbs = errorToCallbacks.get(sig as EProcessSignals); //does this array of callbacks of this iteration<
  9.             proc.on(sig, (): void => {
  10.                 ...
  11.                 currCloseCbs.map((cb) => cb()); //will be a closure while calling this
  12.                 ...
  13.             });
  14.         }
  15.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top