2020-05-10 04:24:46 -07:00
|
|
|
import { api } from '/api';
|
|
|
|
import { store } from '/store';
|
|
|
|
|
|
|
|
import urbitOb from 'urbit-ob';
|
|
|
|
|
|
|
|
|
|
|
|
export class Subscription {
|
|
|
|
start() {
|
|
|
|
if (api.authTokens) {
|
2020-05-23 05:29:33 -07:00
|
|
|
this.initializebartinfo();
|
2020-05-10 04:24:46 -07:00
|
|
|
} else {
|
|
|
|
console.error("~~~ ERROR: Must set api.authTokens before operation ~~~");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-23 05:29:33 -07:00
|
|
|
initializebartinfo() {
|
2020-05-31 04:28:47 -07:00
|
|
|
/*
|
2020-05-23 05:29:33 -07:00
|
|
|
api.bind('/primary', 'PUT', api.authTokens.ship, 'bartinfo',
|
|
|
|
this.handleEvent.bind(this),
|
|
|
|
this.handleError.bind(this));
|
2020-05-31 04:28:47 -07:00
|
|
|
*/
|
|
|
|
|
2020-06-03 03:30:21 -07:00
|
|
|
api.bind("/routes", "PUT", api.authTokens.ship, "bartinfo",
|
|
|
|
this.handleEvent.bind(this),
|
|
|
|
this.handleError.bind(this));
|
|
|
|
|
2020-06-01 00:24:08 -07:00
|
|
|
api.bind("/elevators", "PUT", api.authTokens.ship, "bartinfo",
|
|
|
|
this.handleEvent.bind(this),
|
|
|
|
this.handleError.bind(this));
|
|
|
|
|
|
|
|
api.bind("/bartstations", "PUT", api.authTokens.ship, 'bartinfo',
|
2020-05-31 04:28:47 -07:00
|
|
|
this.handleEvent.bind(this),
|
|
|
|
this.handleError.bind(this));
|
|
|
|
|
2020-05-23 05:29:33 -07:00
|
|
|
}
|
2020-05-10 04:24:46 -07:00
|
|
|
|
|
|
|
handleEvent(diff) {
|
|
|
|
store.handleEvent(diff);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleError(err) {
|
|
|
|
console.error(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export let subscription = new Subscription();
|