reflux-store-cache-mixin
Advanced tools
Comparing version 0.0.4 to 0.0.5
{ | ||
"name": "reflux-store-cache-mixin", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Reflux store chaching mixin to reduce unnecessary calls", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
# reflux-store-cache-mixin | ||
Reflux mixin for chaching data. | ||
Reflux mixin for caching data. | ||
@@ -34,14 +34,17 @@ Main usage is to reduce network calls for slowly changing data | ||
onFetchAll() { | ||
const data = this.fetchData('data', '*'); | ||
onFetch() { | ||
this.loadData('data', '*', (data, saveNewData) => { | ||
if (! data) { | ||
return fetchData() | ||
.then((nextData) => { | ||
this.data = nextData; | ||
return this.trigger(this.data); | ||
}); | ||
} | ||
if (! data) { | ||
return fetchData() | ||
.tap(saveNewData) | ||
.then((nextData) => { | ||
this.data = nextData; | ||
return this.trigger(this.data); | ||
}); | ||
} | ||
return this.trigger(this.data); | ||
return this.trigger(this.data); | ||
}); | ||
}, | ||
@@ -48,0 +51,0 @@ }); |
14983
54