Replies: 3 comments
-
My first thought: it should not be in the core, since strategy could be different. For But we can get some optional helper for 80% of use cases. |
Beta Was this translation helpful? Give feedback.
0 replies
-
The optional helper can have a callback with a |
Beta Was this translation helpful? Give feedback.
0 replies
-
Something like: import { task, stale } from 'nanostores'
import { $userId, $user } from './user-stores.js'
async function fetchUser() {
await task(async () => {
stale(isSlated => {
let response = await fetch(`https://my-api/users/${$userId.get()}`)
if (isSlated()) return
$user.set(await response.json())
})
})
} Hm, how we will track different calls? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Let's say
task
was used to fetch a resource & the responses come out of order. Should nanostores have a mechanism intask
(or another function) to handle out of order (stale) promises or should that be a user-land solution?See #229 & https://github.com/orgs/nanostores/discussions/216
Beta Was this translation helpful? Give feedback.
All reactions