diff options
author | kumavis <kumavis@users.noreply.github.com> | 2017-10-19 06:09:32 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-19 06:09:32 +0800 |
commit | 8da0d0b28a52d476da3623774159e8d6a595da2d (patch) | |
tree | d35cd3391ca2dda9626f6076cbff1e3da0e02c97 /app/scripts/lib/events-proxy.js | |
parent | 5eeb1440468cb77111fd09d01b85b4b9a5264766 (diff) | |
download | tangerine-wallet-browser-8da0d0b28a52d476da3623774159e8d6a595da2d.tar tangerine-wallet-browser-8da0d0b28a52d476da3623774159e8d6a595da2d.tar.gz tangerine-wallet-browser-8da0d0b28a52d476da3623774159e8d6a595da2d.tar.bz2 tangerine-wallet-browser-8da0d0b28a52d476da3623774159e8d6a595da2d.tar.lz tangerine-wallet-browser-8da0d0b28a52d476da3623774159e8d6a595da2d.tar.xz tangerine-wallet-browser-8da0d0b28a52d476da3623774159e8d6a595da2d.tar.zst tangerine-wallet-browser-8da0d0b28a52d476da3623774159e8d6a595da2d.zip |
Revert "NetworkController refactor for new EthClient interface"
Diffstat (limited to 'app/scripts/lib/events-proxy.js')
-rw-r--r-- | app/scripts/lib/events-proxy.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/app/scripts/lib/events-proxy.js b/app/scripts/lib/events-proxy.js index 840b06b1a..d1199a278 100644 --- a/app/scripts/lib/events-proxy.js +++ b/app/scripts/lib/events-proxy.js @@ -1,5 +1,6 @@ -module.exports = function createEventEmitterProxy(eventEmitter, eventHandlers = {}) { +module.exports = function createEventEmitterProxy(eventEmitter, listeners) { let target = eventEmitter + const eventHandlers = listeners || {} const proxy = new Proxy({}, { get: (obj, name) => { // intercept listeners @@ -13,12 +14,9 @@ module.exports = function createEventEmitterProxy(eventEmitter, eventHandlers = return true }, }) - proxy.setTarget(eventEmitter) - return proxy - function setTarget (eventEmitter) { target = eventEmitter - // migrate eventHandlers + // migrate listeners Object.keys(eventHandlers).forEach((name) => { eventHandlers[name].forEach((handler) => target.on(name, handler)) }) @@ -28,4 +26,6 @@ module.exports = function createEventEmitterProxy(eventEmitter, eventHandlers = eventHandlers[name].push(handler) target.on(name, handler) } + if (listeners) proxy.setTarget(eventEmitter) + return proxy }
\ No newline at end of file |