-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Hi!
I don't known if the docs are wrong or if this is not working as intended, but when running this example:
const posts = asyncable(async ($path, $query) => {
if ($path.toString() === '/posts') {
const res = await fetch(`/posts?page=${$query.params.page || 1}`);
return res.json();
}
},
null,
[ path, query ]
);
... the store will always be updated. That is because an async function (the getter in this case) will always return a Promise
. In this case either the return value of res.json()
or a Promise<undefined>
. If we instead do this:
const posts = asyncable(($path, $query) => {
if ($path.toString() === '/posts') {
return fetch(`/posts?page=${$query.params.page || 1}`).then(res => res.json());
}
},
null,
[ path, query ]
);
... it will work as stated in the docs because now the return type is either a Promise
or undefined
(not Promise<undefined>
).
IMO this shouldn't matter. If the getter returns either undefined
or Promise<undefined>
no update should be triggered.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request