Skip to content

Commit

Permalink
Switched from waitForAwaitable to yieldAwaitable
Browse files Browse the repository at this point in the history
  • Loading branch information
BobDickinson committed Apr 9, 2016
1 parent e250b42 commit be340a2
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions button.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports.View =
title: "Buttons",
elements:
[
{ control: "button", caption: "Button", foreground: "CornflowerBlue", background: "Black", width: 125, binding: "text" },
{ control: "button", caption: "Button", foreground: "CornflowerBlue", background: "Black", binding: "text" },
{ control: "button", resource: imgCloud, width: 125, height: 125, binding: "image" },
{ control: "text", value: "{message}", fontsize: 12 },
]
Expand All @@ -33,14 +33,14 @@ exports.Commands =
{
viewModel.message = "Caption button";
yield Synchro.interimUpdateAwaitable(context);
yield Synchro.waitForAwaitable(context, waitInterval, 1000);
yield Synchro.yieldAwaitable(context, function(callback){ waitInterval(1000, callback) });;
viewModel.message = "";
},
image: function * (context, session, viewModel)
{
viewModel.message = "Image button";
yield Synchro.interimUpdateAwaitable(context);
yield Synchro.waitForAwaitable(context, waitInterval, 1000);
yield Synchro.yieldAwaitable(context, function(callback){ waitInterval(1000, callback) });;
viewModel.message = "";
},
}
4 changes: 2 additions & 2 deletions canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ exports.Commands =
{
viewModel.message = "Red tapped";
yield Synchro.interimUpdateAwaitable(context);
yield Synchro.waitForAwaitable(context, waitInterval, 1000);
yield Synchro.yieldAwaitable(context, function(callback){ waitInterval(1000, callback) });;
viewModel.message = "";
},
greenTapped: function * (context, session, viewModel)
{
viewModel.message = "Green tapped";
yield Synchro.interimUpdateAwaitable(context);
yield Synchro.waitForAwaitable(context, waitInterval, 1000);
yield Synchro.yieldAwaitable(context, function(callback){ waitInterval(1000, callback) });;
viewModel.message = "";
},
}
4 changes: 2 additions & 2 deletions countdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ exports.InitializeViewModel = function(context, session)

exports.LoadViewModel = function * (context, session, viewModel)
{
yield Synchro.waitForAwaitable(context, waitInterval, 4000);
yield Synchro.yieldAwaitable(context, function(callback){ waitInterval(4000, callback) });;
viewModel.count = 10;
viewModel.isLoading = false;
}
Expand All @@ -49,7 +49,7 @@ exports.Commands =

while (viewModel.isCounting && (viewModel.count > 0))
{
yield Synchro.waitForAwaitable(context, waitInterval, 1000);
yield Synchro.yieldAwaitable(context, function(callback){ waitInterval(1000, callback) });;
if (viewModel.isCounting)
{
viewModel.count--;
Expand Down
2 changes: 1 addition & 1 deletion image.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ exports.Commands =
viewModel.message = "Image tapped: " + params.count;
var thisTap = ++viewModel.nextTap;
yield Synchro.interimUpdateAwaitable(context);
yield Synchro.waitForAwaitable(context, waitInterval, 1000);
yield Synchro.yieldAwaitable(context, function(callback){ waitInterval(1000, callback) });;
if (thisTap == viewModel.nextTap)
{
// If no other taps came in during the wait, then let's clear the message...
Expand Down
2 changes: 1 addition & 1 deletion list.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exports.InitializeViewModel = function(context, session)
{
itemToAdd: "",
items: [ "white", "black", "yellow" ],
selectedItems: [ "black" ],
selectedItems: [ "black" ]
}
return viewModel;
}
Expand Down
3 changes: 2 additions & 1 deletion react.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ exports.InitializeViewModel = function(context, session)

exports.LoadViewModel = function * (context, session, viewModel)
{
viewModel.responseData = JSON.parse((yield Synchro.waitForAwaitable(context, request, { url: REQUEST_URL }))[0].body);
var response = yield Synchro.yieldAwaitable(context, function(callback){ request({ url: REQUEST_URL }, callback) });
viewModel.responseData = JSON.parse(response[0].body);
}
3 changes: 2 additions & 1 deletion react2.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ exports.InitializeViewModel = function(context, session)

exports.LoadViewModel = function * (context, session, viewModel)
{
viewModel.responseData = JSON.parse((yield Synchro.waitForAwaitable(context, request, { url: REQUEST_URL }))[0].body);
var response = yield Synchro.yieldAwaitable(context, function(callback){ request({ url: REQUEST_URL }, callback) });
viewModel.responseData = JSON.parse(response[0].body);
}

0 comments on commit be340a2

Please sign in to comment.