Some code cleanup
This commit is contained in:
parent
5f219f00f5
commit
42da0d9ee3
@ -22,6 +22,7 @@ class Store {
|
|||||||
handleEvent(data) {
|
handleEvent(data) {
|
||||||
let json = data.data;
|
let json = data.data;
|
||||||
|
|
||||||
|
console.log("Storing event");
|
||||||
console.log(json);
|
console.log(json);
|
||||||
this.initialReducer.reduce(json, this.state);
|
this.initialReducer.reduce(json, this.state);
|
||||||
this.configReducer.reduce(json, this.state);
|
this.configReducer.reduce(json, this.state);
|
||||||
|
@ -6,9 +6,7 @@ import urbitOb from 'urbit-ob';
|
|||||||
|
|
||||||
export class Subscription {
|
export class Subscription {
|
||||||
start() {
|
start() {
|
||||||
console.log("Calling start()")
|
|
||||||
if (api.authTokens) {
|
if (api.authTokens) {
|
||||||
console.log("would initialize");
|
|
||||||
this.initializebartinfo();
|
this.initializebartinfo();
|
||||||
} else {
|
} else {
|
||||||
console.error("~~~ ERROR: Must set api.authTokens before operation ~~~");
|
console.error("~~~ ERROR: Must set api.authTokens before operation ~~~");
|
||||||
@ -16,7 +14,6 @@ export class Subscription {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initializebartinfo() {
|
initializebartinfo() {
|
||||||
console.log("Initialize bart info");
|
|
||||||
api.bind('/primary', 'PUT', api.authTokens.ship, 'bartinfo',
|
api.bind('/primary', 'PUT', api.authTokens.ship, 'bartinfo',
|
||||||
this.handleEvent.bind(this),
|
this.handleEvent.bind(this),
|
||||||
this.handleError.bind(this));
|
this.handleError.bind(this));
|
||||||
@ -28,11 +25,6 @@ export class Subscription {
|
|||||||
|
|
||||||
handleError(err) {
|
handleError(err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
/*
|
|
||||||
api.bind('/primary', 'PUT', api.authTokens.ship, 'bartinfo',
|
|
||||||
this.handleEvent.bind(this),
|
|
||||||
this.handleError.bind(this));
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,8 +59,6 @@
|
|||||||
%print-chutney ~& "CHUTNEY" [~ this]
|
%print-chutney ~& "CHUTNEY" [~ this]
|
||||||
%print-state ~& this [~ this]
|
%print-state ~& this [~ this]
|
||||||
%give-number [[%give %fact ~[/primary] %json !>(*json)]~ 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
|
%handle-http-request
|
||||||
=+ !<([eyre-id=@ta =inbound-request:eyre] vase)
|
=+ !<([eyre-id=@ta =inbound-request:eyre] vase)
|
||||||
@ -73,15 +71,15 @@
|
|||||||
::
|
::
|
||||||
++ on-watch
|
++ on-watch
|
||||||
|= =path
|
|= =path
|
||||||
^- (quip card:agent:gall _this)
|
^- (quip card _this)
|
||||||
~& "on-watch path: {<path>}"
|
~& "on-watch path: {<path>}"
|
||||||
?: ?=([%primary *] path)
|
?: ?=([%primary *] path)
|
||||||
=/ initial-resp [%give %fact ~ %json !>((bogus-json:cc))]
|
=/ initial-resp [%give %fact ~ %json !>((bogus-json:cc))]
|
||||||
=/ out *outbound-config:iris
|
=/ bart-station-request
|
||||||
=/ req request-bart-stations:cc
|
=/ out *outbound-config:iris
|
||||||
::=/ bart-station-request [%pass /[(scot %da now.bol)] %arvo %i %request req out]
|
=/ req bart-api-request-stations:cc
|
||||||
=/ bart-station-request [%pass /bartstationrequest %arvo %i %request req out]
|
[%pass /bartstationrequest %arvo %i %request req out]
|
||||||
[[initial-resp bart-station-request ~] this]
|
[~[initial-resp bart-station-request] this]
|
||||||
?: ?=([%http-response *] path)
|
?: ?=([%http-response *] path)
|
||||||
`this
|
`this
|
||||||
?. =(/ path)
|
?. =(/ path)
|
||||||
@ -93,13 +91,14 @@
|
|||||||
++ on-arvo
|
++ on-arvo
|
||||||
|= [=wire =sign-arvo]
|
|= [=wire =sign-arvo]
|
||||||
^- (quip card _this)
|
^- (quip card _this)
|
||||||
|
~& "on-arvo wire: {<wire>}"
|
||||||
?: ?=(%http-response +<.sign-arvo)
|
?: ?=(%http-response +<.sign-arvo)
|
||||||
~& "WIRE: {<wire>}"
|
=/ http-moves=(list card)
|
||||||
::~& "SIGN ARVO: {<sign-arvo>}"
|
=/ value %- pairs:enjs:format
|
||||||
=/ value %- pairs:enjs:format
|
:~ fulltext+s+(crip "{<sign-arvo>}")
|
||||||
:~ fulltext+s+(crip "{<sign-arvo>}")
|
==
|
||||||
==
|
[%give %fact ~[/primary] %json !>(value)]~
|
||||||
[[%give %fact ~[/primary] %json !>(value)]~ this]
|
[http-moves this]
|
||||||
?. ?=(%bound +<.sign-arvo)
|
?. ?=(%bound +<.sign-arvo)
|
||||||
(on-arvo:def wire sign-arvo)
|
(on-arvo:def wire sign-arvo)
|
||||||
[~ this]
|
[~ this]
|
||||||
@ -116,9 +115,14 @@
|
|||||||
::
|
::
|
||||||
:: request to http://api.bart.gov/api/stn.aspx?cmd=stns&key=Q5RQ-PUEB-999T-DWEI&json=y
|
:: request to http://api.bart.gov/api/stn.aspx?cmd=stns&key=Q5RQ-PUEB-999T-DWEI&json=y
|
||||||
:: get .root | .stations | .station for list of stations
|
:: get .root | .stations | .station for list of stations
|
||||||
|
|
||||||
++ bart-api-key "Q5RQ-PUEB-999T-DWEI"
|
++ bart-api-key "Q5RQ-PUEB-999T-DWEI"
|
||||||
++ bart-api-url-base "http://api.bart.gov/api"
|
++ bart-api-url-base "http://api.bart.gov/api"
|
||||||
|
++ bart-api-request-stations
|
||||||
|
^- request:http
|
||||||
|
=/ url (crip "{bart-api-url-base}/stn.aspx?cmd=stns&key={bart-api-key}&json=y")
|
||||||
|
=/ headers [['Accept' 'application/json']]~
|
||||||
|
[%'GET' url headers *(unit octs)]
|
||||||
|
::
|
||||||
++ poke-handle-http-request
|
++ poke-handle-http-request
|
||||||
|= =inbound-request:eyre
|
|= =inbound-request:eyre
|
||||||
^- simple-payload:http
|
^- simple-payload:http
|
||||||
@ -145,17 +149,4 @@
|
|||||||
:~
|
:~
|
||||||
success+b+%.y
|
success+b+%.y
|
||||||
==
|
==
|
||||||
++ request-bart-stations
|
|
||||||
^- request:http
|
|
||||||
=/ url (crip "{bart-api-url-base}/stn.aspx?cmd=stns&key={bart-api-key}&json=y")
|
|
||||||
=/ headers [['Accept' 'application/json']]~
|
|
||||||
[%'GET' url headers *(unit octs)]
|
|
||||||
::;++ request-darksky
|
|
||||||
:: |= location=@t
|
|
||||||
:: ^- request:http
|
|
||||||
:: =/ base 'https://api.darksky.net/forecast/634639c10670c7376dc66b6692fe57ca/'
|
|
||||||
:: =/ url=@t (cat 3 (cat 3 base location) '?units=auto')
|
|
||||||
:: =/ hed [['Accept' 'application/json']]~
|
|
||||||
:: [%'GET' url hed *(unit octs)]
|
|
||||||
::
|
|
||||||
--
|
--
|
||||||
|
Loading…
Reference in New Issue
Block a user