Skip to content

Commit 07a45f4

Browse files
authored
deprecated useTask$ eagerness (#7345)
* deprecated eagerness * reviewd changes * added changeset
1 parent 73e8fcc commit 07a45f4

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

.changeset/poor-numbers-yawn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@builder.io/qwik': minor
3+
---
4+
5+
The `useTask$` function's `eagerness` option is deprecated and will be removed in version 2.

packages/docs/src/routes/api/qwik/api.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@
726726
}
727727
],
728728
"kind": "TypeAlias",
729-
"content": "```typescript\nexport type EagernessOptions = 'visible' | 'load' | 'idle';\n```",
729+
"content": "> Warning: This API is now obsolete.\n> \n> use useVisibleTask$ or useResource$, useTask$ is for running tasks as part of the initial SSR render\n> \n\n\n```typescript\nexport type EagernessOptions = 'visible' | 'load' | 'idle';\n```",
730730
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-task.ts",
731731
"mdFile": "qwik.eagernessoptions.md"
732732
},
@@ -1774,7 +1774,7 @@
17741774
}
17751775
],
17761776
"kind": "Function",
1777-
"content": "> This API is provided as an alpha preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.\n> \n\nInstall a service worker which will prefetch the bundles.\n\nThere can only be one service worker per page. Because there can be many separate Qwik Containers on the page each container needs to load its prefetch graph using `PrefetchGraph` component.\n\n\n```typescript\nPrefetchServiceWorker: (opts: {\n base?: string;\n scope?: string;\n path?: string;\n verbose?: boolean;\n fetchBundleGraph?: boolean;\n nonce?: string;\n}) => JSXNode<'script'>\n```\n\n\n<table><thead><tr><th>\n\nParameter\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\nopts\n\n\n</td><td>\n\n{ base?: string; scope?: string; path?: string; verbose?: boolean; fetchBundleGraph?: boolean; nonce?: string; }\n\n\n</td><td>\n\nOptions for the prefetch service worker.\n\n- `base` - Base URL for the service worker `import.meta.env.BASE_URL` or `/`<!-- -->. Default is `import.meta.env.BASE_URL` - `scope` - Base URL for when the service-worker will activate. Default is `/` - `path` - Path to the service worker. Default is `qwik-prefetch-service-worker.js` unless you pass a path that starts with a `/` then the base is ignored. Default is `qwik-prefetch-service-worker.js` - `verbose` - Verbose logging for the service worker installation. Default is `false` - `nonce` - Optional nonce value for security purposes, defaults to `undefined`<!-- -->.\n\n\n</td></tr>\n</tbody></table>\n**Returns:**\n\nJSXNode&lt;'script'&gt;",
1777+
"content": "> This API is provided as an alpha preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.\n> \n\nInstall a service worker which will prefetch the bundles.\n\nThere can only be one service worker per page. Because there can be many separate Qwik Containers on the page each container needs to load its prefetch graph using `PrefetchGraph` component.\n\n\n```typescript\nPrefetchServiceWorker: (opts: {\n base?: string;\n scope?: string;\n path?: string;\n verbose?: boolean;\n fetchBundleGraph?: boolean;\n nonce?: string;\n}) => JSXNode<'script'>\n```\n\n\n<table><thead><tr><th>\n\nParameter\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\nopts\n\n\n</td><td>\n\n{ base?: string; scope?: string; path?: string; verbose?: boolean; fetchBundleGraph?: boolean; nonce?: string; }\n\n\n</td><td>\n\nOptions for the prefetch service worker.\n\n- `base` - Base URL for the service worker `import.meta.env.BASE_URL` or `/`<!-- -->. Default is `import.meta.env.BASE_URL` - `scope` - Base URL for when the service-worker will activate. Default is `/` - `path` - Path to the service worker. Default is `qwik-prefetch-service-worker.js` unless you pass a path that starts with a `/` then the base is ignored. Default is `qwik-prefetch-service-worker.js` - `verbose` - Verbose logging for the service worker installation. Default is `false` - `nonce` - Optional nonce value for security purposes, defaults to `undefined`<!-- -->.\n\n\n</td></tr>\n</tbody></table>\n**Returns:**\n\n[JSXNode](#jsxnode)<!-- -->&lt;'script'&gt;",
17781778
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/components/prefetch.ts",
17791779
"mdFile": "qwik.prefetchserviceworker.md"
17801780
},
@@ -3356,7 +3356,7 @@
33563356
}
33573357
],
33583358
"kind": "Interface",
3359-
"content": "```typescript\nexport interface UseTaskOptions \n```\n\n\n<table><thead><tr><th>\n\nProperty\n\n\n</th><th>\n\nModifiers\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\n[eagerness?](#)\n\n\n</td><td>\n\n\n</td><td>\n\n[EagernessOptions](#eagernessoptions)\n\n\n</td><td>\n\n_(Optional)_ - `visible`<!-- -->: run the effect when the element is visible. - `load`<!-- -->: eagerly run the effect when the application resumes.\n\n\n</td></tr>\n</tbody></table>",
3359+
"content": "> Warning: This API is now obsolete.\n> \n> use useVisibleTask$ or useResource$, useTask$ is for running tasks as part of the initial SSR render\n> \n\n\n```typescript\nexport interface UseTaskOptions \n```\n\n\n<table><thead><tr><th>\n\nProperty\n\n\n</th><th>\n\nModifiers\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\n[eagerness?](#)\n\n\n</td><td>\n\n\n</td><td>\n\n[EagernessOptions](#eagernessoptions)\n\n\n</td><td>\n\n_(Optional)_ - `visible`<!-- -->: run the effect when the element is visible. - `load`<!-- -->: eagerly run the effect when the application resumes.\n\n\n</td></tr>\n</tbody></table>",
33603360
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-task.ts",
33613361
"mdFile": "qwik.usetaskoptions.md"
33623362
},

packages/docs/src/routes/api/qwik/index.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2052,6 +2052,10 @@ _(Optional)_
20522052
20532053
## EagernessOptions
20542054
2055+
> Warning: This API is now obsolete.
2056+
>
2057+
> use useVisibleTask$ or useResource$, useTask$ is for running tasks as part of the initial SSR render
2058+
20552059
```typescript
20562060
export type EagernessOptions = "visible" | "load" | "idle";
20572061
```
@@ -3653,7 +3657,7 @@ Options for the prefetch service worker.
36533657
</tbody></table>
36543658
**Returns:**
36553659
3656-
JSXNode&lt;'script'&gt;
3660+
[JSXNode](#jsxnode)&lt;'script'&gt;
36573661
36583662
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/components/prefetch.ts)
36593663
@@ -11291,6 +11295,10 @@ void
1129111295
1129211296
## UseTaskOptions
1129311297
11298+
> Warning: This API is now obsolete.
11299+
>
11300+
> use useVisibleTask$ or useResource$, useTask$ is for running tasks as part of the initial SSR render
11301+
1129411302
```typescript
1129511303
export interface UseTaskOptions
1129611304
```

packages/qwik/src/core/api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export interface DOMAttributes<EL extends Element> extends DOMAttributesBase<EL>
217217
class?: ClassList | Signal<ClassList> | undefined;
218218
}
219219

220-
// @public (undocumented)
220+
// @public @deprecated (undocumented)
221221
export type EagernessOptions = 'visible' | 'load' | 'idle';
222222

223223
// @public (undocumented)
@@ -1728,7 +1728,7 @@ export const useStylesScopedQrl: (styles: QRL<string>) => UseStylesScoped;
17281728
// @public
17291729
export const useTask$: (qrl: TaskFn, opts?: UseTaskOptions | undefined) => void;
17301730

1731-
// @public (undocumented)
1731+
// @public @deprecated (undocumented)
17321732
export interface UseTaskOptions {
17331733
eagerness?: EagernessOptions;
17341734
}

packages/qwik/src/core/use/use-task.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export interface DescriptorBase<T = unknown, B = unknown> {
186186
$state$: B | undefined;
187187
}
188188

189-
/** @public */
189+
/** @public @deprecated use useVisibleTask$ or useResource$, useTask$ is for running tasks as part of the initial SSR render */
190190
export type EagernessOptions = 'visible' | 'load' | 'idle';
191191

192192
/** @public */
@@ -207,7 +207,7 @@ export interface OnVisibleTaskOptions {
207207
strategy?: VisibleTaskStrategy;
208208
}
209209

210-
/** @public */
210+
/** @public @deprecated use useVisibleTask$ or useResource$, useTask$ is for running tasks as part of the initial SSR render */
211211
export interface UseTaskOptions {
212212
/**
213213
* - `visible`: run the effect when the element is visible.

0 commit comments

Comments
 (0)