-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(useAsync$): implement RFC 324 #8301
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
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
680bbd9
feat(useAsync$): pollMs option
wmertens 2f00c1c
feat(useAsync$): add pollMs accessor
wmertens 8537839
feat(useAsync$): resume polling on the client from qidle
wmertens efa0a01
changeset
wmertens 94adbfe
feat(useAsync$): add `initial` option
wmertens 94876f7
perf(signal): small memory improvement
wmertens e9ed051
fix(core): don't crash on missing container
wmertens 4380740
refactor(container): single pending count
wmertens 93636f3
refactor(useAsync$): wait for load on server
wmertens 05ea38f
fix(computed): always run effects on change
wmertens de64bea
refactor(async): improve cleanup handling and signal management
wmertens 86c9e76
feat(async): `concurrency` option
wmertens 1743b47
feat(async): abort signal support
wmertens 56b823f
chore: pnpm dedupe
wmertens fe442bb
chore(docs): document `useAsync$` and update examples
wmertens 8798758
fix(core): don't crash when printing vnode
wmertens d644a26
feat(async): `timeout`
wmertens 70ea99d
fix(async): some edge cases
wmertens 6f9200a
chore(core): remove resource tasks :tada:
wmertens e6c80e6
chore(docs): remove useResource mentions
wmertens 0e6f119
chore: rename pollMs to interval
wmertens 8c95150
feat(async): eagerCleanup
wmertens 9856df5
feat(async): support `reason` in abort
wmertens 054348d
chore: lint++
wmertens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@qwik.dev/core': major | ||
| --- | ||
|
|
||
| BREAKING: the `.promise()` method on `useAsync$` now returns a `Promise<void>` instead of `Promise<T>`, to avoid having to put `.catch()` on every call and to promote using the reactive `result.value` and `result.error` properties for handling async results and errors. | ||
| - the default serialization strategy for `useAsync$` is now 'always' instead of 'never', because it is likely to be expensive to get. | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| '@qwik.dev/core': minor | ||
| --- | ||
|
|
||
| FEAT: `useAsync$()` now has `interval`, which re-runs the compute function on intervals. You can change signal.interval to enable/disable it, and if you set it during SSR it will automatically resume to do the polling. | ||
| This way, you can auto-update data on the client without needing to set up timers or events. For example, you can show a "time ago" string that updates every minute, or you can poll an API for updates, and change the poll interval when the window goes idle. | ||
|
|
||
| - FEAT: `useAsync$()` now has a `concurrency` option, which limits the number of concurrent executions of the compute function. If a new execution is triggered while the limit is reached, it will wait for the previous ones to finish before starting. This is useful for preventing overload when the compute function is expensive or when it involves network requests. The default value is 1, which means that a new execution will wait for the previous one to finish before starting. Setting it to 0 allows unlimited concurrent executions. | ||
| In-flight invocations will update the signal value only if they complete before a newer invocation completes. For example, if you have a search input that triggers a new `useAsync$` execution on every keystroke, results will show in the correct order. | ||
|
|
||
| - FEAT: `useAsync$()` now has an `abort()` method, which aborts the current computation and runs cleanups if needed. This allows you to cancel long-running tasks when they are no longer needed, such as when a component unmounts or when a new computation starts. The compute function needs to use the `abortSignal` provided to handle aborts gracefully. | ||
| When a new computation starts, the previous computation will be aborted via the abortSignal. This allows you to prevent unnecessary work and ensure that only the latest computation is active. For example, if you have a search input that triggers a new `useAsync$` execution on every keystroke, the previous search will be aborted when a new one starts, ensuring that only the latest search is performed. | ||
wmertens marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@qwik.dev/core': minor | ||
| --- | ||
|
|
||
| DEPRECATION: `useResource$` and `<Resource />` are now deprecated. `useAsync$` is more efficient, more flexible, and easier to use. Use `concurrency: 0` to have the same behavior as `useResource$`. |
This file contains hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.