From 4152c86032d2a73df9dcace972d69b614e8d47d6 Mon Sep 17 00:00:00 2001 From: Josh Perez Date: Tue, 26 May 2015 22:26:38 -0700 Subject: [PATCH] [changed] local fetches on null or undefined --- .eslintrc | 2 +- docs/async.md | 4 ++-- src/alt/store/StoreMixin.js | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.eslintrc b/.eslintrc index ba7f5699..de698e0a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -51,7 +51,7 @@ "eqeqeq": 2, "guard-for-in": 2, "no-caller": 2, - "no-eq-null": 2, + "no-eq-null": 0, "no-eval": 2, "no-extend-native": 2, "no-extra-bind": 2, diff --git a/docs/async.md b/docs/async.md index ed1eff9a..26572b79 100644 --- a/docs/async.md +++ b/docs/async.md @@ -45,7 +45,7 @@ const SearchSource = { }; ``` -You then tie this to a store using the `exportAsync` function in the constructor. +You then tie this to a store using the `registerAsync` function in the constructor. ```js class SearchStore { @@ -85,7 +85,7 @@ This function is called first. If a value is returned then a change event will b ### remote(state: object, ...args: any) -This function is called whenever we need to fetch a value remotely. This is determined if `local` returns a falsy value. +This function is called whenever we need to fetch a value remotely. `remote` is only called if `local` returns null or undefined as its value, or if `shouldFetch` returns true. Any arguments passed to your public method will be passed through to both local and remote: diff --git a/src/alt/store/StoreMixin.js b/src/alt/store/StoreMixin.js index 2c4e4dbf..cd1aae86 100644 --- a/src/alt/store/StoreMixin.js +++ b/src/alt/store/StoreMixin.js @@ -46,7 +46,9 @@ const StoreMixin = { publicMethods[methodName] = (...args) => { const state = this.getInstance().getState() const value = spec.local && spec.local(state, ...args) - const shouldFetch = spec.shouldFetch ? spec.shouldFetch(state, ...args) : !value + const shouldFetch = spec.shouldFetch + ? spec.shouldFetch(state, ...args) + : value == null const intercept = spec.interceptResponse || (x => x) // if we don't have it in cache then fetch it