diff --git a/lib/api/index.js b/lib/api/index.js index 565ed01e..64f33599 100644 --- a/lib/api/index.js +++ b/lib/api/index.js @@ -28,6 +28,10 @@ class PublicAPI { registerInterceptor(interceptor) { this.interceptor = interceptor; + + if (!this.enabled) { + this.interceptor.disable(); + } } connect(options) { @@ -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); }