Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/funny-feet-wish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eslint-plugin-qwik': minor
---

feat: add eslint rule for resolving async computed
5 changes: 5 additions & 0 deletions .changeset/polite-parents-win.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@qwik.dev/core': minor
---

feat: add resolve method for async computed
19 changes: 18 additions & 1 deletion packages/docs/src/routes/api/qwik/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
}
],
"kind": "Interface",
"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>",
"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>",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/reactive-primitives/signal.public.ts",
"mdFile": "core.asynccomputedreadonlysignal.md"
},
Expand Down Expand Up @@ -1745,6 +1745,23 @@
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/ssr/ssr-types.ts",
"mdFile": "core.renderssroptions.md"
},
{
"name": "resolve",
"id": "asynccomputedreadonlysignal-resolve",
"hierarchy": [
{
"name": "AsyncComputedReadonlySignal",
"id": "asynccomputedreadonlysignal-resolve"
},
{
"name": "resolve",
"id": "asynccomputedreadonlysignal-resolve"
}
],
"kind": "MethodSignature",
"content": "```typescript\nresolve(): Promise<void>;\n```\n**Returns:**\n\nPromise&lt;void&gt;",
"mdFile": "core.asynccomputedreadonlysignal.resolve.md"
},
{
"name": "Resource",
"id": "resource",
Expand Down
28 changes: 28 additions & 0 deletions packages/docs/src/routes/api/qwik/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,24 @@ Whether the signal is currently loading.
</td></tr>
</tbody></table>

<table><thead><tr><th>

Method

</th><th>

Description

</th></tr></thead>
<tbody><tr><td>

[resolve()](#asynccomputedreadonlysignal-resolve)

</td><td>

</td></tr>
</tbody></table>

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/reactive-primitives/signal.public.ts)

## AsyncComputedReturnType
Expand Down Expand Up @@ -3469,6 +3487,16 @@ StreamWriter

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/ssr/ssr-types.ts)

## resolve

```typescript
resolve(): Promise<void>;
```

**Returns:**

Promise&lt;void&gt;

## Resource

This method works like an async memoized function that runs whenever some tracked value changes and returns some data.
Expand Down
4 changes: 4 additions & 0 deletions packages/eslint-plugin-qwik/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { validLexicalScope } from './src/validLexicalScope';
import { serializerSignalUsage } from './src/serializerSignalUsage';
import pkg from './package.json';
import { scopeUseTask } from './src/scope-use-task';
import { asyncComputedTop } from './src/asyncComputedTop';

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

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

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

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

const configs = {
Expand Down
Loading
Loading