Skip to content

Commit

Permalink
settings on change return data to watch
Browse files Browse the repository at this point in the history
  • Loading branch information
Rytiggy committed Apr 14, 2018
1 parent a77dd7d commit 2c48cf2
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions Glance/companion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,8 @@ function returnData(data) {

}

// Listen for messages from the device
messaging.peerSocket.onmessage = function(evt) {
if (evt.data) {

let weatherPromise = new Promise(function(resolve, reject) {
function formatReturnData() {
let weatherPromise = new Promise(function(resolve, reject) {
resolve( queryOpenWeather() );
});

Expand All @@ -116,8 +113,18 @@ messaging.peerSocket.onmessage = function(evt) {
returnData(dataToSend)
});
}


// Listen for messages from the device
messaging.peerSocket.onmessage = function(evt) {
if (evt.data) {
formatReturnData()
}
}




// Listen for the onerror event
messaging.peerSocket.onerror = function(err) {
// Handle any errors
Expand All @@ -130,10 +137,10 @@ messaging.peerSocket.onerror = function(err) {
// This section deals with settings
//
//----------------------------------------------------------
// settingsStorage.onchange = function(evt) {
// console.log( getSettings(evt.key) )

// }
settingsStorage.onchange = function(evt) {
console.log( getSettings(evt.key) )
formatReturnData()
}

// getters
function getSettings(key) {
Expand Down

0 comments on commit 2c48cf2

Please sign in to comment.