emit only if activated

pull/5370/head
yann300 2 years ago committed by Aniket
parent 6ab8a212ab
commit e480c776d0
  1. 4
      apps/remix-ide/src/blockchain/blockchain.js

@ -31,6 +31,7 @@ export class Blockchain extends Plugin {
// NOTE: the config object will need to be refactored out in remix-lib
constructor (config) {
super(profile)
this.active = false
this.event = new EventManager()
this.executionContext = new ExecutionContext()
@ -55,11 +56,13 @@ export class Blockchain extends Plugin {
}
_triggerEvent (name, args) {
if (!this.active) return
this.event.trigger(name, args)
this.emit(name, ...args)
}
onActivation () {
this.active = true
this.on('injected', 'chainChanged', () => {
this.detectNetwork((error, network) => {
this.networkStatus = { network, error }
@ -76,6 +79,7 @@ export class Blockchain extends Plugin {
}
onDeactivation () {
this.active = false
this.off('injected', 'chainChanged')
this.off('injected-trustwallet', 'chainChanged')
}

Loading…
Cancel
Save