Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache JestHook emitters #8746

Merged
merged 2 commits into from Aug 3, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Next

Cache JestHook emitters

  • Loading branch information
Connormiha committed Jul 24, 2019
commit ae46cc1b44991048b5d5cc3e5ce279e36a1556e8
@@ -25,20 +25,17 @@ class JestHooks {
shouldRunTestSuite: Array<ShouldRunTestSuite>;
};

private _subscriber: JestHookSubscriber;
private _emitter: JestHookEmitter;

constructor() {
this._listeners = {
onFileChange: [],
onTestRunComplete: [],
shouldRunTestSuite: [],
};
}

isUsed(hook: AvailableHooks) {
return this._listeners[hook] && this._listeners[hook].length;
}

getSubscriber(): JestHookSubscriber {
return {
this._subscriber = {
onFileChange: fn => {
this._listeners.onFileChange.push(fn);
},
@@ -49,10 +46,8 @@ class JestHooks {
this._listeners.shouldRunTestSuite.push(fn);
},
};
}

getEmitter(): JestHookEmitter {
return {
this._emitter = {
onFileChange: fs =>
this._listeners.onFileChange.forEach(listener => listener(fs)),
onTestRunComplete: results =>
@@ -70,6 +65,18 @@ class JestHooks {
},
};
}

isUsed(hook: AvailableHooks) {
return this._listeners[hook] && this._listeners[hook].length;
}

getSubscriber(): Readonly<JestHookSubscriber> {
return this._subscriber;
}

getEmitter(): Readonly<JestHookEmitter> {
return this._emitter;
}
}

export default JestHooks;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.