From 3c0f46099301856f92e6721837346c5182eb4a81 Mon Sep 17 00:00:00 2001 From: ronreg-ribdev <56719257+ronreg-ribdev@users.noreply.github.com> Date: Sat, 23 May 2020 05:29:33 -0700 Subject: [PATCH] Successfully sending something to frontend --- src/js/api.js | 1 + src/js/subscription.js | 17 +++++++++++------ urbit/app/bartinfo.hoon | 14 +++++++++++++- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/js/api.js b/src/js/api.js index 30db2db..4996096 100644 --- a/src/js/api.js +++ b/src/js/api.js @@ -9,6 +9,7 @@ class UrbitApi { } bind(path, method, ship = this.authTokens.ship, appl = "bartinfo", success, fail) { + console.log(`Calling api.bind() with path ${path} ship ${ship} method ${method}`); this.bindPaths = _.uniq([...this.bindPaths, path]); window.subscriptionId = window.urb.subscribe(ship, appl, path, diff --git a/src/js/subscription.js b/src/js/subscription.js index e549e4e..c8d1158 100644 --- a/src/js/subscription.js +++ b/src/js/subscription.js @@ -6,18 +6,21 @@ import urbitOb from 'urbit-ob'; export class Subscription { start() { + console.log("Calling start()") if (api.authTokens) { - // this.initializebartinfo(); + console.log("would initialize"); + this.initializebartinfo(); } else { console.error("~~~ ERROR: Must set api.authTokens before operation ~~~"); } } - // initializebartinfo() { - // api.bind('/primary', 'PUT', api.authTokens.ship, 'bartinfo', - // this.handleEvent.bind(this), - // this.handleError.bind(this)); - // } + initializebartinfo() { + console.log("Initialize bart info"); + api.bind('/primary', 'PUT', api.authTokens.ship, 'bartinfo', + this.handleEvent.bind(this), + this.handleError.bind(this)); + } handleEvent(diff) { store.handleEvent(diff); @@ -25,9 +28,11 @@ export class Subscription { handleError(err) { console.error(err); + /* api.bind('/primary', 'PUT', api.authTokens.ship, 'bartinfo', this.handleEvent.bind(this), this.handleError.bind(this)); + */ } } diff --git a/urbit/app/bartinfo.hoon b/urbit/app/bartinfo.hoon index 624ef86..dab4d24 100644 --- a/urbit/app/bartinfo.hoon +++ b/urbit/app/bartinfo.hoon @@ -54,6 +54,14 @@ ^- (quip card _this) ?> (team:title our.bol src.bol) ?+ mark (on-poke:def mark vase) + %noun + ?+ q.vase (on-poke:def mark vase) + %print-chutney ~& "CHUTNEY" [~ this] + %print-state ~& this [~ this] + %give-number [[%give %fact ~[/primary] %json !>(*json)]~ this] + ::%yolo [[%give %fact ~ %noun [@ 299]]~ this] + ::%hella [[%give %fact ~ %json !>((bogus-json:cc))]~ this] + == %handle-http-request =+ !<([eyre-id=@ta =inbound-request:eyre] vase) :_ this @@ -66,6 +74,10 @@ ++ on-watch |= =path ^- (quip card:agent:gall _this) + ~& "on-watch path: {}" + ?: ?=([%primary *] path) + :_ this + [%give %fact ~ %json !>((bogus-json:cc))]~ ?: ?=([%http-response *] path) `this ?. =(/ path) @@ -120,7 +132,7 @@ ^- json %- pairs:enjs:format :~ - success+b+%.n + success+b+%.y == ++ request-bart-stations ^- request:http