Created
February 12, 2020 18:47
-
-
Save jaysoo/4eb21671c0c7336dcbe5eebcac414b74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fetchUsers = createAsyncThunk( | |
"users/fetch", | |
(function () { | |
// use `p` to ensure promises are returned in order. | |
let p = Promise.resolve(); | |
return () => { | |
// Wait for previous promise to resolve first to guarantee ordering. | |
return p.then(() => { | |
// Change binding to new API call. | |
p = usersAPI.fetchAll(); | |
// Return current promise. | |
return p; | |
}) | |
} | |
})() | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment