Hey all. I'm new to Monkey C, though am a JavaScript developer by trade.
I'm trying to build a widget for my watch, but getting a bit stuck in callback ***. Wondering if there's anyone that can offer guidance, or if there are any discord/irc servers for Monkey C development that I can hang in.
My main issue at the moment is that on getInitialView()
I am doing a web request that will eventually set off other web requests, but i'm struggling to get the data that is returned from the web request back into getInitialView()
.
So my Widget code looks a little like this:
function getInitialView() as [Views] or [Views, InputDelegates] {
System.println("hello! Lat and Long!");
var pos = Position.getInfo().position.toDegrees();
var places = place.getPlaceByLocation(pos[0], pos[1], 100.0);
System.println(places);
}
null
. Within my place
class, it looks like this:using Toybox.Lang;
class Place extends API {
hidden var placeURL;
hidden var data;
var places;
function initialize() {
API.initialize();
placeURL = "/Place/";
}
function getPlaceByLocation(lat as Lang.Float, lon as Lang.Float, radius as Lang.Double) {
var url = self.placeURL + "?Lat=" + lat + "&Lon=" + lon + "&radius=" + radius.format("%.2f");
return makeRequest(url, method(:setPlacesByLocation));
}
function setPlacesByLocation() {
System.println("got here");
places = new Places(API.getData());
return places;
}
}
setPlacesByLocation()
function is being called after the makeRequest
is called and is correctly creating a Places instance... however, that is happening after the println
in getInitialView
.getInitialView
?