aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-20 13:44:33 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-20 13:44:33 -0500
commit2519f99f54412933beed8b2c753c76662099f8e0 (patch)
tree4fc453e375394749ad1cd5d1e1fb72cafef84048 /ext/mixed
parent2a95f1420f08b034ae8e12ecffed86aa6f33e53a (diff)
Update how orphan state is observed
Diffstat (limited to 'ext/mixed')
-rw-r--r--ext/mixed/js/api.js2
-rw-r--r--ext/mixed/js/core.js8
2 files changed, 9 insertions, 1 deletions
diff --git a/ext/mixed/js/api.js b/ext/mixed/js/api.js
index ae74b8dc..18b360a3 100644
--- a/ext/mixed/js/api.js
+++ b/ext/mixed/js/api.js
@@ -115,8 +115,8 @@ function _apiInvoke(action, params={}) {
}
});
} catch (e) {
- window.yomichan_orphaned = true;
reject(e);
+ yomichan.triggerOrphaned(e);
}
});
}
diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js
index a3c8c0b0..5e560a58 100644
--- a/ext/mixed/js/core.js
+++ b/ext/mixed/js/core.js
@@ -244,6 +244,14 @@ const yomichan = (() => {
chrome.runtime.onMessage.addListener(this._onMessage.bind(this));
}
+ // Public
+
+ triggerOrphaned(error) {
+ this.trigger('orphaned', {error});
+ }
+
+ // Private
+
_onMessage({action, params}, sender, callback) {
const handler = this._messageHandlers.get(action);
if (typeof handler !== 'function') { return false; }