aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/port-stream.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-01-17 17:27:25 +0800
committerkumavis <aaron@kumavis.me>2016-01-17 17:27:25 +0800
commit2f079dfdd158b787659e3f87d5c5c442b2f05e7a (patch)
tree6c4a58f812898932ede58a356741cfd2eb877892 /app/scripts/lib/port-stream.js
parente50e1894435e47e3e23a7c97e61ca679cfa3222b (diff)
downloadtangerine-wallet-browser-2f079dfdd158b787659e3f87d5c5c442b2f05e7a.tar
tangerine-wallet-browser-2f079dfdd158b787659e3f87d5c5c442b2f05e7a.tar.gz
tangerine-wallet-browser-2f079dfdd158b787659e3f87d5c5c442b2f05e7a.tar.bz2
tangerine-wallet-browser-2f079dfdd158b787659e3f87d5c5c442b2f05e7a.tar.lz
tangerine-wallet-browser-2f079dfdd158b787659e3f87d5c5c442b2f05e7a.tar.xz
tangerine-wallet-browser-2f079dfdd158b787659e3f87d5c5c442b2f05e7a.tar.zst
tangerine-wallet-browser-2f079dfdd158b787659e3f87d5c5c442b2f05e7a.zip
refactor - push data to popup
Diffstat (limited to 'app/scripts/lib/port-stream.js')
-rw-r--r--app/scripts/lib/port-stream.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/scripts/lib/port-stream.js b/app/scripts/lib/port-stream.js
index d256efc9a..7f3e8072e 100644
--- a/app/scripts/lib/port-stream.js
+++ b/app/scripts/lib/port-stream.js
@@ -12,6 +12,7 @@ function PortDuplexStream(port){
})
this._port = port
port.onMessage.addListener(this._onMessage.bind(this))
+ port.onDisconnect.addListener(this._onDisconnect.bind(this))
}
// private
@@ -21,6 +22,15 @@ PortDuplexStream.prototype._onMessage = function(msg){
this.push(msg)
}
+PortDuplexStream.prototype._onDisconnect = function(msg){
+ // console.log('PortDuplexStream - saw message', msg)
+ try {
+ this.end()
+ } catch(err){
+ this.emit('error', err)
+ }
+}
+
// stream plumbing
PortDuplexStream.prototype._read = noop