Skip to content

Commit

Permalink
fix(Master toggle): Fix master toggle not turning on and off mimic
Browse files Browse the repository at this point in the history
Fix an issue where we did not notify the currently registered interceptor of the new state
  • Loading branch information
morsdyce committed Jun 4, 2018
1 parent 4ff3527 commit 9e9e0ed
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class PublicAPI {

registerInterceptor(interceptor) {
this.interceptor = interceptor;

if (!this.enabled) {
this.interceptor.disable();
}
}

connect(options) {
Expand All @@ -36,11 +40,21 @@ class PublicAPI {

turnOn() {
this.enabled = true;

if (this.interceptor) {
this.interceptor.enable();
}

Emitter.emit(EVENTS.MIMIC_TURN_ON);
}

turnOff() {
this.enabled = false;

if (this.interceptor) {
this.interceptor.disable();
}

Emitter.emit(EVENTS.MIMIC_TURN_OFF);
}

Expand Down

0 comments on commit 9e9e0ed

Please sign in to comment.