Replies: 3 comments 1 reply
|
@simwr872 If you need 'first load OR pending' semantics, Conceptually:
If your use-case is primarily async state + loading lifecycle, Sources: |
|
@simwr872 Can you give me a quick example of how you expect to use this. I want to visualize it. I have an idea, one is have isPending being configurable to show initial isPending. But the most helpful thing is to see usage so O can determine the best payterns. |
|
At the moment I would treat this as “there is no built-in const [resolvedOnce, setResolvedOnce] = createSignal(false);
const value = createMemo(() => {
const v = expensiveOrAsyncSource();
if (!resolvedOnce()) queueMicrotask(() => setResolvedOnce(true));
return v;
});
const isLoadingOrPending = () => !resolvedOnce() || value.isPending;That gives you the semantics you described:
If the thing you are modeling is fundamentally async data with loading/error states, I’d still seriously consider |
Uh oh!
There was an error while loading. Please reload this page.
Hello! Trying out the new 2.0 release. Is there any way to know that a memo is loading, regardless whether it is the first load or not? 2.0 introduced
isPendingbut it will befalseon first load. TheLoadingcomponent is what I need but to have the result stored in a signal. Basically anisLoadingOrPendingfunction.Previously this was possible by using
createResourceand looking at its state.All reactions