diff --git a/src/session.js b/src/session.js index 6b3ae24..58c6b5e 100644 --- a/src/session.js +++ b/src/session.js @@ -1,4 +1,4 @@ -function Session() { +function Session(async) { var game = JSON.parse(localStorage.getItem('game')); var options = JSON.parse(localStorage.getItem('options')) || defaultOptions(); @@ -6,15 +6,24 @@ function Session() { getOptions: getOptions, getGame: getGame, save: save, - setOptions: setOptions + setOptions: setOptions, + update: update }; function getGame() { return game; } - function update(state) { - game = state; + function update() { + return async.bind( + messaging.receive(function(message) { + return message.tag == "Game"; + }), + function(message) { + game = message.contents; + return async.wrap(); + } + ); } function save() {