PolymerElements / app-storage

Data-pipes and specialized services
61 stars 47 forks source link

[Feature Request] - App-indexeddb-mirror Load if offline OR data is empty #138

Open derhuebiii opened 6 years ago

derhuebiii commented 6 years ago

I need this to save AJAX requests for 24 hours for the pixabay API. When the user searches manually I want to check in the locally stored requests if he did this the last 24hours. So I want to check the key without providing anything in data at this time.

I managed to get it work like this, but it would be nice if it would be a property: <app-indexeddb-mirror ... load-from-cache-when-data-empty="true"></app-indexeddb-mirror>

https://github.com/PolymerElements/app-storage/blob/191e31dbfe785a8028bf7f338099a34e11b952fa/app-indexeddb-mirror/app-indexeddb-mirror.html#L240

Changing to: if (this.online && this.data.length != 0) { and: https://github.com/PolymerElements/app-storage/blob/191e31dbfe785a8028bf7f338099a34e11b952fa/app-indexeddb-mirror/app-indexeddb-mirror.html#L248

to: if ((this.online & this.data.length != 0) || !this.client.supportsMirroring) { solves it for me.

Maybe this can be enhanced as a feature for the element? Load cached data if offline OR no data available in "live-data"?