aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/metamask-controller.js
diff options
context:
space:
mode:
authorFrankie <frankie.diamond@gmail.com>2017-01-06 03:06:18 +0800
committerFrankie <frankie.diamond@gmail.com>2017-01-06 03:06:18 +0800
commite62f70660d922b0bf98e7595939f84821eff814a (patch)
treec36841a2976483a239b99b19815e55101f1a827a /app/scripts/metamask-controller.js
parentc22da8450cf5014fb2bf3c96e0df88c70aa39465 (diff)
downloadtangerine-wallet-browser-e62f70660d922b0bf98e7595939f84821eff814a.tar
tangerine-wallet-browser-e62f70660d922b0bf98e7595939f84821eff814a.tar.gz
tangerine-wallet-browser-e62f70660d922b0bf98e7595939f84821eff814a.tar.bz2
tangerine-wallet-browser-e62f70660d922b0bf98e7595939f84821eff814a.tar.lz
tangerine-wallet-browser-e62f70660d922b0bf98e7595939f84821eff814a.tar.xz
tangerine-wallet-browser-e62f70660d922b0bf98e7595939f84821eff814a.tar.zst
tangerine-wallet-browser-e62f70660d922b0bf98e7595939f84821eff814a.zip
MetaMask Controller - Convert to EventEmitter
Diffstat (limited to 'app/scripts/metamask-controller.js')
-rw-r--r--app/scripts/metamask-controller.js11
1 files changed, 5 insertions, 6 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index c0d2f3b4c..2e5b02a7b 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -1,3 +1,4 @@
+const EventEmitter = require('events')
const extend = require('xtend')
const EthStore = require('eth-store')
const MetaMaskProvider = require('web3-provider-engine/zero.js')
@@ -13,12 +14,12 @@ const autoFaucet = require('./lib/auto-faucet')
const nodeify = require('./lib/nodeify')
const IdStoreMigrator = require('./lib/idStore-migrator')
-module.exports = class MetamaskController {
+module.exports = class MetamaskController extends EventEmitter {
constructor (opts) {
+ super()
this.state = { network: 'loading' }
this.opts = opts
- this.listeners = []
this.configManager = new ConfigManager(opts)
this.keyringController = new KeyringController({
configManager: this.configManager,
@@ -62,6 +63,7 @@ module.exports = class MetamaskController {
})
this.ethStore.on('update', this.sendUpdate.bind(this))
+ this.keyringController.on('update', this.sendUpdate.bind(this))
}
getState () {
@@ -165,10 +167,7 @@ module.exports = class MetamaskController {
sendUpdate () {
this.getState()
.then((state) => {
-
- this.listeners.forEach((remote) => {
- remote.sendUpdate(state)
- })
+ this.emit('update', state)
})
}