summaryrefslogtreecommitdiff
path: root/ext/fg/js/api.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-08-09 21:23:05 -0700
committerAlex Yatskov <alex@foosoft.net>2016-08-09 21:23:05 -0700
commite6d821b73143c4825ecf915a7bbf838aa8aa0b9a (patch)
treeae052e2567f47f2de15e26ea2901127717a75196 /ext/fg/js/api.js
parentdcce58fc2eab1f3b23abb90f5ce30536d7dbf1c1 (diff)
Cleanup using promises
Diffstat (limited to 'ext/fg/js/api.js')
-rw-r--r--ext/fg/js/api.js24
1 files changed, 12 insertions, 12 deletions
diff --git a/ext/fg/js/api.js b/ext/fg/js/api.js
index 7316c604..643d0360 100644
--- a/ext/fg/js/api.js
+++ b/ext/fg/js/api.js
@@ -17,26 +17,26 @@
*/
-function bgSendMessage(action, params, callback) {
- chrome.runtime.sendMessage({action, params}, callback);
+function bgSendMessage(action, params) {
+ return new Promise((resolve, reject) => chrome.runtime.sendMessage({action, params}, resolve));
}
-function bgFindTerm(text, callback) {
- bgSendMessage('findTerm', {text}, callback);
+function bgFindTerm(text) {
+ return bgSendMessage('findTerm', {text});
}
-function bgFindKanji(text, callback) {
- bgSendMessage('findKanji', {text}, callback);
+function bgFindKanji(text) {
+ return bgSendMessage('findKanji', {text});
}
-function bgRenderText(data, template, callback) {
- bgSendMessage('renderText', {data, template}, callback);
+function bgRenderText(data, template) {
+ return bgSendMessage('renderText', {data, template});
}
-function bgCanAddDefinitions(definitions, modes, callback) {
- bgSendMessage('canAddDefinitions', {definitions, modes}, callback);
+function bgCanAddDefinitions(definitions, modes) {
+ return bgSendMessage('canAddDefinitions', {definitions, modes});
}
-function bgAddDefinition(definition, mode, callback) {
- bgSendMessage('addDefinition', {definition, mode}, callback);
+function bgAddDefinition(definition, mode) {
+ return bgSendMessage('addDefinition', {definition, mode});
}