Ionic - Firebase - 如何在Firebase中使用Ionic Storage? #askfirebase

时间:2017-07-25 06:56:18

标签: firebase caching firebase-realtime-database ionic3 ionic-storage

我看了Askfirebase video并且他们不建议管理缓存,但是一个简单的测试表明使用Ionic Storage可以帮助在第一次加载时显示数据。如何显示缓存中的数据并将其替换为Firebase中的数据?

我的代码是实现一个简单的聊天信使

<button *ngFor="let event of events | async" ion-item (click)="launchChat(event.$key)">
    <ion-icon name="cafe" item-left></ion-icon>
    {{event.title}}
</button>
this.events = this.db.list("/events/", {
    query: {
        orderByChild: "people/" + queryEmail,
        equalTo: "true"
    }
});

this.events.subscribe((chats) => {
    if (chats) {
        this.storage.set("chats", chats);
    }

    if (chats.length === 0) {
        return this.showError = true;
    }
});

我无法使用&#39; |从缓存加载数据异步&#39;但我需要为ngFor。

请注意,Firebase仍然不支持Web应用程序的永久持久性。

0 个答案:

没有答案