-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(create-resource): Initial implementation of createResource #282
base: main
Are you sure you want to change the base?
Conversation
…rn the current value of the source signal instead
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 2e2d278. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution
✅ Successfully ran 2 targetsSent with 💌 from NxCloud. |
}); | ||
|
||
function load(p: Promise<TValue> | undefined) { | ||
if (p && isPromise(p)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (p && isPromise(p)) { | |
if (isPromise(p)) { |
if (trigger() !== previousTrigger()) { | ||
state.set('refreshing'); | ||
} else { | ||
state.set('pending'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (trigger() !== previousTrigger()) { | |
state.set('refreshing'); | |
} else { | |
state.set('pending'); | |
} | |
state.set(trigger() !== previousTrigger() ? 'refreshing' : 'pending'); | |
const value = signal<TValue | undefined>(options.initialValue); | ||
const error = signal<TError | undefined>(undefined); | ||
const trigger = signal(0); | ||
const state = signal<CreateResourceStatus>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this can be renamed to 'status' thus matching the Type Parameter itself too?
This is exactly what I was looking for! I spent the weekend implementing my own version of this (😅) and was introduced to this PR by @tomer953. Quick question: How is |
Oh I need this... yesterday! I wonder why exactly its working with Promise and not Observables?
|
This PR implements
createResource
and supportsPromise
s only.Open for discussion.
Highly inspired from https://docs.solidjs.com/reference/basic-reactivity/create-resource
Depends on: #281 for
computedPrevious
change.