Skip to content

Commit

Permalink
[changed] local fetches on null or undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
goatslacker committed May 27, 2015
1 parent ed01b04 commit 4152c86
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions docs/async.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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:

Expand Down
4 changes: 3 additions & 1 deletion src/alt/store/StoreMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4152c86

Please sign in to comment.