Skip to content

Commit b14fe22

Browse files
authored
Merge pull request #7881 from QwikDev/v2-async-read-value
feat: add resolve method for async computed
2 parents 65ae071 + 5432199 commit b14fe22

File tree

21 files changed

+561
-2
lines changed

21 files changed

+561
-2
lines changed

.changeset/funny-feet-wish.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-qwik': minor
3+
---
4+
5+
feat: add eslint rule for resolving async computed

.changeset/polite-parents-win.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@qwik.dev/core': minor
3+
---
4+
5+
feat: add resolve method for async computed

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@
244244
}
245245
],
246246
"kind": "Interface",
247-
"content": "```typescript\nexport interface AsyncComputedReadonlySignal<T = unknown> extends ComputedSignal<T> \n```\n**Extends:** [ComputedSignal](#computedsignal)<!-- -->&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[error](#)\n\n\n</td><td>\n\n\n</td><td>\n\nError \\| null\n\n\n</td><td>\n\nThe error that occurred while computing the signal.\n\n\n</td></tr>\n<tr><td>\n\n[loading](#)\n\n\n</td><td>\n\n\n</td><td>\n\nboolean\n\n\n</td><td>\n\nWhether the signal is currently loading.\n\n\n</td></tr>\n</tbody></table>",
247+
"content": "```typescript\nexport interface AsyncComputedReadonlySignal<T = unknown> extends ComputedSignal<T> \n```\n**Extends:** [ComputedSignal](#computedsignal)<!-- -->&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[error](#)\n\n\n</td><td>\n\n\n</td><td>\n\nError \\| null\n\n\n</td><td>\n\nThe error that occurred while computing the signal.\n\n\n</td></tr>\n<tr><td>\n\n[loading](#)\n\n\n</td><td>\n\n\n</td><td>\n\nboolean\n\n\n</td><td>\n\nWhether the signal is currently loading.\n\n\n</td></tr>\n</tbody></table>\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[resolve()](#asynccomputedreadonlysignal-resolve)\n\n\n</td><td>\n\n\n</td></tr>\n</tbody></table>",
248248
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/reactive-primitives/signal.public.ts",
249249
"mdFile": "core.asynccomputedreadonlysignal.md"
250250
},
@@ -1759,6 +1759,23 @@
17591759
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/ssr/ssr-types.ts",
17601760
"mdFile": "core.renderssroptions.md"
17611761
},
1762+
{
1763+
"name": "resolve",
1764+
"id": "asynccomputedreadonlysignal-resolve",
1765+
"hierarchy": [
1766+
{
1767+
"name": "AsyncComputedReadonlySignal",
1768+
"id": "asynccomputedreadonlysignal-resolve"
1769+
},
1770+
{
1771+
"name": "resolve",
1772+
"id": "asynccomputedreadonlysignal-resolve"
1773+
}
1774+
],
1775+
"kind": "MethodSignature",
1776+
"content": "```typescript\nresolve(): Promise<T>;\n```\n**Returns:**\n\nPromise&lt;T&gt;",
1777+
"mdFile": "core.asynccomputedreadonlysignal.resolve.md"
1778+
},
17621779
{
17631780
"name": "Resource",
17641781
"id": "resource",

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,24 @@ Whether the signal is currently loading.
185185
</td></tr>
186186
</tbody></table>
187187
188+
<table><thead><tr><th>
189+
190+
Method
191+
192+
</th><th>
193+
194+
Description
195+
196+
</th></tr></thead>
197+
<tbody><tr><td>
198+
199+
[resolve()](#asynccomputedreadonlysignal-resolve)
200+
201+
</td><td>
202+
203+
</td></tr>
204+
</tbody></table>
205+
188206
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/reactive-primitives/signal.public.ts)
189207
190208
## AsyncComputedReturnType
@@ -3591,6 +3609,16 @@ StreamWriter
35913609
35923610
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/ssr/ssr-types.ts)
35933611
3612+
## resolve
3613+
3614+
```typescript
3615+
resolve(): Promise<T>;
3616+
```
3617+
3618+
**Returns:**
3619+
3620+
Promise&lt;T&gt;
3621+
35943622
## Resource
35953623
35963624
This method works like an async memoized function that runs whenever some tracked value changes and returns some data.

packages/eslint-plugin-qwik/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { validLexicalScope } from './src/validLexicalScope';
1313
import { serializerSignalUsage } from './src/serializerSignalUsage';
1414
import pkg from './package.json';
1515
import { scopeUseTask } from './src/scope-use-task';
16+
import { asyncComputedTop } from './src/asyncComputedTop';
1617

1718
type Rules = NonNullable<TSESLint.FlatConfig.Plugin['rules']>;
1819

@@ -30,6 +31,7 @@ const rules = {
3031
'no-use-visible-task': noUseVisibleTask,
3132
'serializer-signal-usage': serializerSignalUsage,
3233
'scope-use-task': scopeUseTask,
34+
'async-computed-top': asyncComputedTop,
3335
} satisfies Rules;
3436

3537
const recommendedRulesLevels = {
@@ -46,6 +48,7 @@ const recommendedRulesLevels = {
4648
'qwik/no-use-visible-task': 'warn',
4749
'qwik/serializer-signal-usage': 'error',
4850
'qwik/scope-use-task': 'error',
51+
'qwik/async-computed-top': 'warn',
4952
} satisfies TSESLint.FlatConfig.Rules;
5053

5154
const strictRulesLevels = {
@@ -62,6 +65,7 @@ const strictRulesLevels = {
6265
'qwik/no-use-visible-task': 'warn',
6366
'qwik/serializer-signal-usage': 'error',
6467
'qwik/scope-use-task': 'error',
68+
'qwik/async-computed-top': 'warn',
6569
} satisfies TSESLint.FlatConfig.Rules;
6670

6771
const configs = {

0 commit comments

Comments
 (0)