shrub/pkg/interface/timer/tile/api.js

40 lines
732 B
JavaScript
Raw Normal View History

2019-05-29 02:19:07 +03:00
class Api {
bind(app, path, success, fail, ship) {
2020-01-04 00:06:42 +03:00
window.urb.subscribe(ship, app, path,
2019-05-29 02:19:07 +03:00
(err) => {
fail(err, app, path, ship);
},
(event) => {
success({
data: event,
from: {
app,
ship,
path
}
});
},
(err) => {
fail(err, app, path, ship);
});
}
chess(data) {
this.action("chess", "chess-command", data);
}
action(appl, mark, data) {
return new Promise((resolve, reject) => {
window.urb.poke(ship, appl, mark, data,
(json) => {
resolve(json);
2020-01-04 00:06:42 +03:00
},
2019-05-29 02:19:07 +03:00
(err) => {
reject(err);
});
});
}
}
module.exports = new Api();