Skip to content
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

chore: replace async useComputed$ #11

Merged
merged 1 commit into from
Nov 19, 2024
Merged

chore: replace async useComputed$ #11

merged 1 commit into from
Nov 19, 2024

Conversation

gioboa
Copy link
Member

@gioboa gioboa commented Nov 19, 2024

Chore to remove warning

QWIK WARN useComputed$: Async functions in computed tasks are 
deprecated and will stop working in v2. Use useTask$ or useResource$ instead.

Copy link

changeset-bot bot commented Nov 19, 2024

⚠️ No Changeset found

Latest commit: 2ccdacd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@gioboa gioboa merged commit 4ea3a32 into main Nov 19, 2024
2 checks passed
@gioboa gioboa deleted the feat/replace-useComputed branch November 19, 2024 21:21
Comment on lines +232 to +239
useTask$(async ({ track }) => {
const src = track(() => props.src);
const width = track(() => props.width);
const height = track(() => props.height);
const aspectRatio = track(() => props.aspectRatio);
const layout = track(() => props.layout);

srcSetSig.value = await getSrcSet({
Copy link
Member

@wmertens wmertens Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, you can run any sync code you like inside track and track multiple signals at once.

you could so something like await getSrcSet(track(() => props))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for sharing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I just realized that you need to reference the props themselves, so it would be more like await getSrcSet(track(() => ({src: props.src, width: props.width, ...}) or you could destructure in the component top and just list the props in track.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, would you like to create a PR for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants