Skip to content

Commit

Permalink
wrapping with timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
ishandutta2007 committed Sep 2, 2017
1 parent 7b81fec commit bbeefa3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
16 changes: 10 additions & 6 deletions app/main.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
// this import should be first in order to load some required settings (like globals and reflect-metadata)
import { platformNativeScriptDynamic } from "nativescript-angular/platform";
import { FirebaseService } from "./modules/services/firebase.service";
var firebase = require("nativescript-plugin-firebase");

firebase.init({
// Optionally pass in properties for database, authentication and cloud messaging,
// see their respective docs.
}).then(
try {
firebase.init({
// Optionally pass in properties for database, authentication and cloud messaging,
// see their respective docs.
}).then(
function (instance) {
console.log("firebase.init done");
},
function (error) {
console.log("firebase.init error: " + error);
}
);
);
} catch (error) {
console.log("firebase.init doesnt even get called properly: " + error);
}

import { AppModule } from "./modules/app.module";

Expand Down
5 changes: 4 additions & 1 deletion app/modules/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export class HomeComponent implements OnInit {
}

ngOnInit() {
this.channels$ = <any>this.firebaseService.getPath('users/RXmeYtQYTxOUmc6WBnqPFTItyeP2/channels');
this.firebaseService.init();
setTimeout(
this.channels$ = <any>this.firebaseService.getPath('users/RXmeYtQYTxOUmc6WBnqPFTItyeP2/channels'),
9000);
}
}
18 changes: 18 additions & 0 deletions app/modules/services/firebase.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ export class FirebaseService {
private ngZone: NgZone
) { }

public init() {
try {
firebase.init({
// Optionally pass in properties for database, authentication and cloud messaging,
// see their respective docs.
}).then(
function (instance) {
console.log("firebase.init done");
},
function (error) {
console.log("firebase.init error: " + error);
}
);
} catch (error) {
console.log("firebase.init doesnt even get called properly: " + error);
}
}

public getPath(path): Observable<any> {
return new Observable((observer: any) => {
let listener: any;
Expand Down

0 comments on commit bbeefa3

Please sign in to comment.