Created
February 18, 2014 11:42
-
-
Save robwormald/9069421 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.factory('chromeAccountProxy',function(){ | |
var _localAccounts = [] | |
var _isLoggedIn = false; | |
function sendMessage(message){ | |
chrome.extension.sendMessage(message) | |
} | |
function recieveMessage(message,sender,sendResponse){ | |
// new account | |
if(message.action == 'account:add'){ | |
_localAccounts.push(message.account) | |
} | |
if(message.action == 'account:update'){ | |
//find obj in _localAccounts and update | |
} | |
} | |
function addAccount(accountDetails){ | |
sendMessage({action : 'account:create', account : accountDetails}) | |
} | |
//assume we're listening for changes to accounts} | |
chrome.extension.onMessage.addListener(recieveMessage) | |
return { | |
addAccountLocally : _addNewAccount, | |
allAccounts : _localAccounts | |
} | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment