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

feat(v2): new signals implementation #6443

Merged
merged 91 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
c66de56
chore(v2): break circular dependency in imports
mhevery Jun 2, 2024
c8d1d03
WIP
mhevery Jun 2, 2024
e01a0fe
WIP: trying to get computed signals to work
mhevery Jun 2, 2024
3b22893
WIP: tests passing
mhevery Jun 2, 2024
bee49ed
WIP: hook up scheduler
mhevery Jun 2, 2024
e23b4bf
WIP: signals keep track of effects
mhevery Jun 12, 2024
defd5cf
WIP
mhevery Jun 14, 2024
50e4ba3
fixup
wmertens Jun 15, 2024
c7fb41b
wip
wmertens Jun 15, 2024
61220b4
wip fix tests some more
wmertens Jun 15, 2024
e90972f
WIP
mhevery Jun 29, 2024
e832da5
WIP: basic
mhevery Jul 4, 2024
ec285a2
WIP: progress
mhevery Jul 5, 2024
1f7e06a
WIP: another passing test
mhevery Jul 6, 2024
2bd7afe
WIP: use-signal.spec.tsx passing in CSR
mhevery Jul 9, 2024
dbbf276
WIP: serialization refactored, more work needed
mhevery Jul 9, 2024
70c32f6
WIP: most of the use-signal.spec tests pass
mhevery Jul 12, 2024
23a0a66
WIP: use-signal.spec.tsx passing
mhevery Jul 12, 2024
030b4fa
WIP: signals should work started work on stores
mhevery Jul 23, 2024
a4212d7
WIP: update signals
mhevery Jul 23, 2024
2d923a6
fix use-signal tests
Varixo Jul 28, 2024
289ab11
fix some visible task tests
Varixo Jul 28, 2024
4f6045f
wip: use-store.spec passes in CSR mode
mhevery Jul 31, 2024
6a6b609
WIP: basic serialization/deserialization of Store2 working
mhevery Aug 2, 2024
227d9dd
fix store impl
Varixo Aug 6, 2024
087872e
fix useComputed$
Varixo Aug 7, 2024
9e53aa9
fix some use-task and use-visible tests
Varixo Aug 8, 2024
1a53f55
fix ref
Varixo Aug 8, 2024
e91b6dd
fix use computed infinity loop
Varixo Aug 9, 2024
3ef8169
implement qrl resolve chore
Varixo Aug 9, 2024
f287219
remove computed chore
Varixo Aug 9, 2024
4289406
fix v2-signals tests
Varixo Aug 9, 2024
c6cee75
fix isPromise check
Varixo Aug 9, 2024
54aa838
Merge branch 'build/v2' into build/v2-signals
Varixo Aug 9, 2024
9f3c4ee
after merge changes
Varixo Aug 10, 2024
a4ae10a
fix csr use-resource tests
Varixo Aug 10, 2024
a14dc9f
serialization cleanup
Varixo Aug 10, 2024
66185ea
fix some projection tests
Varixo Aug 10, 2024
d6542fa
fix imports
Varixo Aug 10, 2024
ed77433
fix build
Varixo Aug 10, 2024
1b4f133
fix use-task infinity loop
Varixo Aug 10, 2024
39a256a
fix use-resource tests
Varixo Aug 12, 2024
a4dc963
fix get derived signal value
Varixo Aug 14, 2024
33857ae
implement signals cleanup
Varixo Aug 15, 2024
eb917f8
fix execute cleanup task on unmount for ssr
Varixo Aug 16, 2024
03fa2d1
fix store array
Varixo Aug 16, 2024
bdace09
fix build
Varixo Aug 16, 2024
598747e
fix add event to element returned by signal
Varixo Aug 16, 2024
09ab2da
fix no container error
Varixo Aug 17, 2024
4de71a5
fix unnecessary component rerendering
Varixo Aug 18, 2024
a8d830e
replace isSignal with isSignal2 for useresource
Varixo Aug 18, 2024
5c1424c
fix not execute signal when not used
Varixo Aug 18, 2024
6f31c77
fix scoped style id
Varixo Aug 18, 2024
82b7d17
fix projection tests
Varixo Aug 18, 2024
7295bec
fix build
Varixo Aug 18, 2024
80beaf6
fix lint
Varixo Aug 18, 2024
71e388a
change cleanup stale chore call
Varixo Aug 18, 2024
19be81b
Revert "change cleanup stale chore call"
Varixo Aug 19, 2024
3260bd7
fix store serialization and resource tests
Varixo Aug 19, 2024
3c8a4a8
add store toJSON
Varixo Aug 19, 2024
ea6ed77
fix set attributes
Varixo Aug 19, 2024
d10846b
fix qrl resolve chore
Varixo Aug 22, 2024
2417c15
add untrackedValue setter
Varixo Aug 22, 2024
ddfe999
fix attributes tests
Varixo Aug 23, 2024
4d9ac35
fix some e2e tests
Varixo Aug 27, 2024
13f8719
remove isRerunning option
Varixo Aug 27, 2024
f67de35
change cleanup vnode chores
Varixo Aug 27, 2024
9aab08e
skip chores on deleted vnodes
Varixo Aug 27, 2024
38afd9d
add failing tests
Varixo Aug 28, 2024
68c0ea7
Merge branch 'build/v2' into build/v2-signals
Varixo Aug 31, 2024
4fad01e
fix build
Varixo Aug 31, 2024
9b5e492
rename DerivedSignal2 to WrappedSignal
Varixo Aug 31, 2024
36d6fec
fix build
Varixo Aug 31, 2024
8eafb46
add failing test
Varixo Sep 6, 2024
d53bed9
serialize ready value instead of dirty marker and fix store destructu…
Varixo Sep 7, 2024
c6ea29d
fix use-computed lazy evaluation
Varixo Sep 7, 2024
b068ab3
replace ':' with Q_PROPS_SEPARATOR
Varixo Sep 7, 2024
ca8842d
rewrite scheduleRender function
Varixo Sep 12, 2024
fcd3e74
Allow assigning undefined as a new prop in store
Varixo Sep 12, 2024
7600594
change store target from empty class to a real object
Varixo Sep 17, 2024
98e9e08
fix delete store property
Varixo Sep 17, 2024
c5fff76
fix ssr store leak
Varixo Sep 18, 2024
d0b88c7
fix api change
Varixo Sep 19, 2024
31e3bc6
fix signal tracking
Varixo Sep 20, 2024
e706929
move visible task test
Varixo Sep 20, 2024
43729aa
implement subscription cleanup
Varixo Sep 21, 2024
1da95e2
fix unit tests
Varixo Sep 21, 2024
823cfd1
remove v2 from v2 signals names
Varixo Sep 21, 2024
5283258
fix types
Varixo Sep 21, 2024
5b15250
fix types and build
Varixo Sep 21, 2024
02ae97a
change effect node prop data impl
Varixo Sep 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 105 additions & 18 deletions packages/docs/src/routes/api/qwik/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,20 @@
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-task.ts",
"mdFile": "qwik.computedfn.md"
},
{
"name": "ComputedSignal2",
"id": "computedsignal2",
"hierarchy": [
{
"name": "ComputedSignal2",
"id": "computedsignal2"
}
],
"kind": "Interface",
"content": "```typescript\nexport interface ComputedSignal2<T> extends ReadonlySignal2<T> \n```\n**Extends:** [ReadonlySignal2](#readonlysignal2)<!-- -->&lt;T&gt;\n\n\n<table><thead><tr><th>\n\nMethod\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\n[force()](#computedsignal2-force)\n\n\n</td><td>\n\nUse this to force recalculation and running subscribers, for example when the calculated value mutates but remains the same object. Useful for third-party libraries.\n\n\n</td></tr>\n</tbody></table>",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/v2/signal/v2-signal.public.ts",
"mdFile": "qwik.computedsignal2.md"
},
{
"name": "ContextId",
"id": "contextid",
Expand Down Expand Up @@ -562,6 +576,34 @@
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/render/jsx/types/jsx-qwik-attributes.ts",
"mdFile": "qwik.correctedtoggleevent.md"
},
{
"name": "createComputed2$",
"id": "createcomputed2_",
"hierarchy": [
{
"name": "createComputed2$",
"id": "createcomputed2_"
}
],
"kind": "Function",
"content": "```typescript\ncreateComputed2$: <T>(qrl: () => T) => ComputedSignal2<T>\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\nqrl\n\n\n</td><td>\n\n() =&gt; T\n\n\n</td><td>\n\n\n</td></tr>\n</tbody></table>\n**Returns:**\n\n[ComputedSignal2](#computedsignal2)<!-- -->&lt;T&gt;",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/v2/signal/v2-signal.public.ts",
"mdFile": "qwik.createcomputed2_.md"
},
{
"name": "createComputed2Qrl",
"id": "createcomputed2qrl",
"hierarchy": [
{
"name": "createComputed2Qrl",
"id": "createcomputed2qrl"
}
],
"kind": "Function",
"content": "```typescript\ncreateComputed2Qrl: <T>(qrl: QRL<() => T>) => ComputedSignal2<T>\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\nqrl\n\n\n</td><td>\n\n[QRL](#qrl)<!-- -->&lt;() =&gt; T&gt;\n\n\n</td><td>\n\n\n</td></tr>\n</tbody></table>\n**Returns:**\n\n[ComputedSignal2](#computedsignal2)<!-- -->&lt;T&gt;",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/v2/signal/v2-signal.public.ts",
"mdFile": "qwik.createcomputed2qrl.md"
},
{
"name": "createContextId",
"id": "createcontextid",
Expand All @@ -577,18 +619,18 @@
"mdFile": "qwik.createcontextid.md"
},
{
"name": "createSignal",
"id": "createsignal",
"name": "createSignal2",
"id": "createsignal2",
"hierarchy": [
{
"name": "createSignal",
"id": "createsignal"
"name": "createSignal2",
"id": "createsignal2"
}
],
"kind": "Variable",
"content": "> Warning: This API is now obsolete.\n> \n> This is a technology preview\n> \n\nCreates a signal.\n\nIf the initial state is a function, the function is invoked to calculate the actual initial state.\n\n\n```typescript\ncreateSignal: UseSignal\n```",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-signal.ts",
"mdFile": "qwik.createsignal.md"
"content": "```typescript\ncreateSignal2: {\n <T>(): Signal2<T | undefined>;\n <T>(value: T): Signal2<T>;\n}\n```",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/v2/signal/v2-signal.public.ts",
"mdFile": "qwik.createsignal2.md"
},
{
"name": "CSSProperties",
Expand Down Expand Up @@ -791,8 +833,8 @@
}
],
"kind": "Function",
"content": "```typescript\nevent$: <T>(qrl: T) => QRL<T>\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\nqrl\n\n\n</td><td>\n\nT\n\n\n</td><td>\n\n\n</td></tr>\n</tbody></table>\n**Returns:**\n\n[QRL](#qrl)<!-- -->&lt;T&gt;",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/qrl/qrl.public.ts",
"content": "```typescript\nevent$: <T>(qrl: T) => import(\"./qrl.public\").QRL<T>\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\nqrl\n\n\n</td><td>\n\nT\n\n\n</td><td>\n\n\n</td></tr>\n</tbody></table>\n**Returns:**\n\nimport(\"./qrl.public\").[QRL](#qrl)<!-- -->&lt;T&gt;",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/qrl/qrl.public.dollar.ts",
"mdFile": "qwik.event_.md"
},
{
Expand Down Expand Up @@ -837,6 +879,23 @@
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/render/jsx/types/jsx-generated.ts",
"mdFile": "qwik.fieldsethtmlattributes.md"
},
{
"name": "force",
"id": "computedsignal2-force",
"hierarchy": [
{
"name": "ComputedSignal2",
"id": "computedsignal2-force"
},
{
"name": "force",
"id": "computedsignal2-force"
}
],
"kind": "MethodSignature",
"content": "Use this to force recalculation and running subscribers, for example when the calculated value mutates but remains the same object. Useful for third-party libraries.\n\n\n```typescript\nforce(): void;\n```\n**Returns:**\n\nvoid",
"mdFile": "qwik.computedsignal2.force.md"
},
{
"name": "FormHTMLAttributes",
"id": "formhtmlattributes",
Expand Down Expand Up @@ -1158,8 +1217,8 @@
}
],
"kind": "Function",
"content": "Checks if a given object is a `Signal`<!-- -->.\n\n\n```typescript\nisSignal: <T = unknown>(obj: any) => obj is Signal<T>\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\nobj\n\n\n</td><td>\n\nany\n\n\n</td><td>\n\nThe object to check if `Signal`<!-- -->.\n\n\n</td></tr>\n</tbody></table>\n**Returns:**\n\nobj is [Signal](#signal)<!-- -->&lt;T&gt;\n\nBoolean - True if the object is a `Signal`<!-- -->.",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/state/signal.ts",
"content": "```typescript\nisSignal2: (value: any) => value is ISignal2<unknown>\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\nvalue\n\n\n</td><td>\n\nany\n\n\n</td><td>\n\n\n</td></tr>\n</tbody></table>\n**Returns:**\n\nvalue is [ISignal2](#signal2)<!-- -->&lt;unknown&gt;",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/v2/signal/v2-signal.ts",
"mdFile": "qwik.issignal.md"
},
{
Expand Down Expand Up @@ -2240,6 +2299,20 @@
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/state/signal.ts",
"mdFile": "qwik.readonlysignal.md"
},
{
"name": "ReadonlySignal2",
"id": "readonlysignal2",
"hierarchy": [
{
"name": "ReadonlySignal2",
"id": "readonlysignal2"
}
],
"kind": "Interface",
"content": "```typescript\nexport interface ReadonlySignal2<T> \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[untrackedValue](#)\n\n\n</td><td>\n\n`readonly`\n\n\n</td><td>\n\nT\n\n\n</td><td>\n\n\n</td></tr>\n<tr><td>\n\n[value](#)\n\n\n</td><td>\n\n`readonly`\n\n\n</td><td>\n\nT\n\n\n</td><td>\n\n\n</td></tr>\n</tbody></table>",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/v2/signal/v2-signal.public.ts",
"mdFile": "qwik.readonlysignal2.md"
},
{
"name": "render",
"id": "render",
Expand Down Expand Up @@ -2492,6 +2565,20 @@
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/state/signal.ts",
"mdFile": "qwik.signal.md"
},
{
"name": "Signal2",
"id": "signal2",
"hierarchy": [
{
"name": "Signal2",
"id": "signal2"
}
],
"kind": "Interface",
"content": "```typescript\nexport interface Signal2<T> extends ReadonlySignal2<T> \n```\n**Extends:** [ReadonlySignal2](#readonlysignal2)<!-- -->&lt;T&gt;\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[untrackedValue](#)\n\n\n</td><td>\n\n\n</td><td>\n\nT\n\n\n</td><td>\n\n\n</td></tr>\n<tr><td>\n\n[value](#)\n\n\n</td><td>\n\n\n</td><td>\n\nT\n\n\n</td><td>\n\n\n</td></tr>\n</tbody></table>",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/v2/signal/v2-signal.public.ts",
"mdFile": "qwik.signal2.md"
},
{
"name": "Size",
"id": "size",
Expand Down Expand Up @@ -2979,7 +3066,7 @@
],
"kind": "Variable",
"content": "```typescript\nuseComputed$: Computed\n```",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-task.ts",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-task-dollar.ts",
"mdFile": "qwik.usecomputed_.md"
},
{
Expand Down Expand Up @@ -3160,7 +3247,7 @@
}
],
"kind": "Variable",
"content": "Hook that creates a signal that is retained for the lifetime of the component.\n\n\n```typescript\nuseSignal: UseSignal\n```",
"content": "```typescript\nuseSignal: UseSignal\n```",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-signal.ts",
"mdFile": "qwik.usesignal.md"
},
Expand All @@ -3174,7 +3261,7 @@
}
],
"kind": "Interface",
"content": "Hook that creates a signal that is retained for the lifetime of the component.\n\n\n```typescript\nuseSignal: UseSignal\n```",
"content": "```typescript\nuseSignal: UseSignal\n```",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-signal.ts",
"mdFile": "qwik.usesignal.md"
},
Expand Down Expand Up @@ -3286,8 +3373,8 @@
}
],
"kind": "Function",
"content": "Reruns the `taskFn` when the observed inputs change.\n\nUse `useTask` to observe changes on a set of inputs, and then re-execute the `taskFn` when those inputs change.\n\nThe `taskFn` only executes if the observed inputs change. To observe the inputs, use the `obs` function to wrap property reads. This creates subscriptions that will trigger the `taskFn` to rerun.\n\n\n```typescript\nuseTask$: (qrl: TaskFn, opts?: UseTaskOptions | undefined) => void\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\nqrl\n\n\n</td><td>\n\n[TaskFn](#taskfn)\n\n\n</td><td>\n\n\n</td></tr>\n<tr><td>\n\nopts\n\n\n</td><td>\n\n[UseTaskOptions](#usetaskoptions) \\| undefined\n\n\n</td><td>\n\n_(Optional)_\n\n\n</td></tr>\n</tbody></table>\n**Returns:**\n\nvoid",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-task.ts",
"content": "Reruns the `taskFn` when the observed inputs change.\n\nUse `useTask` to observe changes on a set of inputs, and then re-execute the `taskFn` when those inputs change.\n\nThe `taskFn` only executes if the observed inputs change. To observe the inputs, use the `obs` function to wrap property reads. This creates subscriptions that will trigger the `taskFn` to rerun.\n\n\n```typescript\nuseTask$: (qrl: import(\"./use-task\").TaskFn, opts?: import(\"./use-task\").UseTaskOptions | undefined) => void\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\nqrl\n\n\n</td><td>\n\nimport(\"./use-task\").[TaskFn](#taskfn)\n\n\n</td><td>\n\n\n</td></tr>\n<tr><td>\n\nopts\n\n\n</td><td>\n\nimport(\"./use-task\").[UseTaskOptions](#usetaskoptions) \\| undefined\n\n\n</td><td>\n\n_(Optional)_\n\n\n</td></tr>\n</tbody></table>\n**Returns:**\n\nvoid",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-task-dollar.ts",
"mdFile": "qwik.usetask_.md"
},
{
Expand Down Expand Up @@ -3328,8 +3415,8 @@
}
],
"kind": "Function",
"content": "```tsx\nconst Timer = component$(() => {\n const store = useStore({\n count: 0,\n });\n\n useVisibleTask$(() => {\n // Only runs in the client\n const timer = setInterval(() => {\n store.count++;\n }, 500);\n return () => {\n clearInterval(timer);\n };\n });\n\n return <div>{store.count}</div>;\n});\n```\n\n\n```typescript\nuseVisibleTask$: (qrl: TaskFn, opts?: OnVisibleTaskOptions | undefined) => void\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\nqrl\n\n\n</td><td>\n\n[TaskFn](#taskfn)\n\n\n</td><td>\n\n\n</td></tr>\n<tr><td>\n\nopts\n\n\n</td><td>\n\n[OnVisibleTaskOptions](#onvisibletaskoptions) \\| undefined\n\n\n</td><td>\n\n_(Optional)_\n\n\n</td></tr>\n</tbody></table>\n**Returns:**\n\nvoid",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-task.ts",
"content": "```tsx\nconst Timer = component$(() => {\n const store = useStore({\n count: 0,\n });\n\n useVisibleTask$(() => {\n // Only runs in the client\n const timer = setInterval(() => {\n store.count++;\n }, 500);\n return () => {\n clearInterval(timer);\n };\n });\n\n return <div>{store.count}</div>;\n});\n```\n\n\n```typescript\nuseVisibleTask$: (qrl: import(\"./use-task\").TaskFn, opts?: import(\"./use-task\").OnVisibleTaskOptions | undefined) => void\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\nqrl\n\n\n</td><td>\n\nimport(\"./use-task\").[TaskFn](#taskfn)\n\n\n</td><td>\n\n\n</td></tr>\n<tr><td>\n\nopts\n\n\n</td><td>\n\nimport(\"./use-task\").[OnVisibleTaskOptions](#onvisibletaskoptions) \\| undefined\n\n\n</td><td>\n\n_(Optional)_\n\n\n</td></tr>\n</tbody></table>\n**Returns:**\n\nvoid",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-task-dollar.ts",
"mdFile": "qwik.usevisibletask_.md"
},
{
Expand Down
Loading
Loading