Skip to content

Commit ee42cdb

Browse files
dejar firebase si cargo primero que loki
1 parent 110a413 commit ee42cdb

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

www/js/app.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66
angular.module('starter', ['ionic', 'lokijs', 'firebase'])
77

88
.run(function($ionicPlatform) {
9+
10+
console.time('$ionicPlatform')
11+
console.time('firebase')
12+
console.time('loki')
13+
914
$ionicPlatform.ready(function() {
15+
console.timeEnd('$ionicPlatform')
1016
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
1117
// for form inputs)
1218
if(window.cordova && window.cordova.plugins.Keyboard) {

www/js/birthday.service.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ var db, birthdays, fbA, tm, temp;
77
]);
88

99
function BirthdayService($q, Loki, $firebaseArray, $timeout, $interval, $ionicPlatform) {
10-
10+
1111

1212
var _db;
13-
tm=$timeout;
13+
tm = $timeout;
1414

1515
var _birthdays;
1616
var _alreadyLoad = null;
17+
var _fbAlreadyLoad = false;
1718
var _temp;
1819
var _ref = new Firebase("https://scm-loki.firebaseio.com/");
1920
var _bdRef = _ref.child('birthdays');
@@ -23,8 +24,9 @@ var db, birthdays, fbA, tm, temp;
2324

2425
_bd.$loaded()
2526
.then(function(res) {
27+
_fbAlreadyLoad = true;
2628
console.log('array loaded', res);
27-
29+
console.timeEnd('firebase')
2830
})
2931
.catch(function(err) {
3032
console.log('cant loaded info from fb', err);
@@ -78,6 +80,7 @@ var db, birthdays, fbA, tm, temp;
7880
})
7981
.then(function() {
8082
_db.loadDatabase(options, function() {
83+
console.timeEnd('loki');
8184
_alreadyLoad = true;
8285
loading = false;
8386
validateBirthDayCollection();
@@ -201,7 +204,13 @@ var db, birthdays, fbA, tm, temp;
201204

202205
function dbOK() {
203206
// service.emu = _birthdays.data;
204-
return _birthdays.data;
207+
208+
if (_fbAlreadyLoad) {
209+
return _bd;
210+
} else {
211+
return _birthdays.data;
212+
}
213+
205214
}
206215
}
207216

0 commit comments

Comments
 (0)