I am trying to run chrome.runtime.sendMessage
to get the information from the server. I am using this information to determine which page to display in my chrome extension. The problem is chrome.runtime.sendMessage is an async function and it is not jiving well with app.config. Is there a way I can turn chrome.runtime.sendMessage
into a synchronous function?
app.config(function($stateProvider, $urlRouterProvider) {
var rootRef = new Firebase(some url);
var user = rootRef.getAuth();
chrome.runtime.sendMessage({action: 'isDrawing'},function(res) {
if (!user) {
$urlRouterProvider.otherwise('/login');
} else if (res.isDrawing === 'true') {
$urlRouterProvider.otherwise('/draw');
} else {
$urlRouterProvider.otherwise('/main');
}
});