adriancarriger / angularfire2-offline

🔌 A simple wrapper for AngularFire2 to read and write to Firebase while offline, even after a complete refresh.
https://angularfire2-offline.firebaseapp.com/
MIT License
207 stars 48 forks source link

Angularfire2 data read is not happening when device going offline #79

Open sarathscs opened 6 years ago

sarathscs commented 6 years ago

Hi,

I am using following ionic configuration with angular 2.

 ordova CLI: 7.1.0
Ionic Framework Version: 3.7.1
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 2.1.4
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v6.10.0
Xcode version: Not installed

I am using this ionic application for android. I enabled the angularfire2 offline.

import {
  AfoListObservable,
  AfoObjectObservable,
  AngularFireOfflineDatabase } from 'angularfire2-offline/database';

  constructor(
    private afoDatabase: AngularFireOfflineDatabase){
   this.dashboardChannel = 'dashboard_'+ id;
    this.dashboardItems = this.afoDatabase.list('/'+this.dashboardChannel);
}
getdataOffline(){
  console.log('OFFLINE')
  this.afoDatabase.list('/' + this.dashboardChannel, { preserveSnapshot: true })
  .subscribe(snapshots => {
    snapshots.forEach(snapshot => {
      console.log(snapshot.key, snapshot.val());
      this.Lists = snapshot.val()
    });
  })
}

I am saving the data to firebase when i am online..If the user is offline i will call the getdataOffline method .But am not getting data when i am going offline. I am not using service worker concept .Only using Angularfire2 offline. Please suggest. I really got stuck in this issue