diff --git a/examples/stock-poller/main.w b/examples/stock-poller/main.w index 54314e5..80bbcd6 100644 --- a/examples/stock-poller/main.w +++ b/examples/stock-poller/main.w @@ -31,19 +31,19 @@ let stockUpdatesPoller = stockUpdatesFetchSchedule.onTick(inflight () => { log("Status: ${stockUpdates.status}"); log("Body: ${stockUpdates.body}"); - if let stockUpdatesBody = stockUpdates.body { - log("Received this stock updates: ${stockUpdatesBody}"); + let stockUpdatesBody = stockUpdates.body; + + log("Received this stock updates: ${stockUpdatesBody}"); - let stockUpdatesBodyJson = Json.parse(stockUpdatesBody); - let latestStockPriceStr = stockUpdatesBodyJson.get("values").getAt(0).get("close").asStr(); - let latestStockPrice = num.fromStr(latestStockPriceStr); + let stockUpdatesBodyJson = Json.parse(stockUpdatesBody); + let latestStockPriceStr = stockUpdatesBodyJson.get("values").getAt(0).get("close").asStr(); + let latestStockPrice = num.fromStr(latestStockPriceStr); - let previousStockPrice = recentStockPriceCache.peek(tickerSymbol); - log("Stock price for ${tickerSymbol} changed from ${previousStockPrice} to ${latestStockPrice} with a difference of: ${latestStockPrice - previousStockPrice}"); + let previousStockPrice = recentStockPriceCache.peek(tickerSymbol); + log("Stock price for ${tickerSymbol} changed from ${previousStockPrice} to ${latestStockPrice} with a difference of: ${latestStockPrice - previousStockPrice}"); - recentStockPriceCache.set(latestStockPrice, tickerSymbol); - stockUpdatesQueue.push(stockUpdatesBody); - } else { - throw("Failed to parse stockUpdates body"); - } + recentStockPriceCache.set(latestStockPrice, tickerSymbol); + stockUpdatesQueue.push(stockUpdatesBody); + + }); diff --git a/examples/todo-app/main.w b/examples/todo-app/main.w index 90fc131..ca165bc 100644 --- a/examples/todo-app/main.w +++ b/examples/todo-app/main.w @@ -151,10 +151,8 @@ class TaskService { // the system will fetch a random task from the internet if description == "random" { let response = http.get("https://www.boredapi.com/api/activity"); - if let responseBody = response.body { - let body = Json.parse(responseBody); - description = str.fromJson(body.get("activity")); - } + let body = Json.parse(response.body); + description = str.fromJson(body.get("activity")); } let id = this.taskStorage.add(description); return {