format: apply repo prettier (3.8.1) to the folded skills tree
963 markdown files reformatted with the repository's pinned prettier so pnpm format:check covers the folded tree like every other repo file. The formatter's embedded-language pass also normalized code fences (TS semicolons, closed HTML tags in examples, lowercased CSS hex colors, one renumbered list that skipped an index). Alphanumeric token deltas vs the fold commit were audited file-by-file; all are formatter-equivalent markup normalizations plus the four sanitized skills.
This commit is contained in:
@@ -11,19 +11,23 @@ Combine computed and inject
|
||||
In Provider Component
|
||||
|
||||
```ts twoslash include main
|
||||
import type { InjectionKey, Ref } from 'vue'
|
||||
import { provide } from 'vue'
|
||||
import type { InjectionKey, Ref } from 'vue';
|
||||
import { provide } from 'vue';
|
||||
|
||||
interface Item {
|
||||
key: number
|
||||
value: string
|
||||
key: number;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export const ArrayKey: InjectionKey<Ref<Item[]>> = Symbol('symbol-key')
|
||||
export const ArrayKey: InjectionKey<Ref<Item[]>> = Symbol('symbol-key');
|
||||
|
||||
const array = ref([{ key: 1, value: '1' }, { key: 2, value: '2' }, { key: 3, value: '3' }])
|
||||
const array = ref([
|
||||
{ key: 1, value: '1' },
|
||||
{ key: 2, value: '2' },
|
||||
{ key: 3, value: '3' },
|
||||
]);
|
||||
|
||||
provide(ArrayKey, array)
|
||||
provide(ArrayKey, array);
|
||||
```
|
||||
|
||||
In Receiver Component
|
||||
@@ -32,55 +36,49 @@ In Receiver Component
|
||||
// @filename: provider.ts
|
||||
// @include: main
|
||||
// ---cut---
|
||||
import { computedInject } from '@vueuse/core'
|
||||
import { computedInject } from '@vueuse/core';
|
||||
|
||||
import { ArrayKey } from './provider'
|
||||
import { ArrayKey } from './provider';
|
||||
|
||||
const computedArray = computedInject(ArrayKey, (source) => {
|
||||
const arr = [...source.value]
|
||||
arr.unshift({ key: 0, value: 'all' })
|
||||
return arr
|
||||
})
|
||||
const arr = [...source.value];
|
||||
arr.unshift({ key: 0, value: 'all' });
|
||||
return arr;
|
||||
});
|
||||
```
|
||||
|
||||
## Type Declarations
|
||||
|
||||
```ts
|
||||
export type ComputedInjectGetter<T, K> = (
|
||||
source: T | undefined,
|
||||
oldValue?: K,
|
||||
) => K
|
||||
export type ComputedInjectGetterWithDefault<T, K> = (
|
||||
source: T,
|
||||
oldValue?: K,
|
||||
) => K
|
||||
export type ComputedInjectSetter<T> = (v: T) => void
|
||||
export type ComputedInjectGetter<T, K> = (source: T | undefined, oldValue?: K) => K;
|
||||
export type ComputedInjectGetterWithDefault<T, K> = (source: T, oldValue?: K) => K;
|
||||
export type ComputedInjectSetter<T> = (v: T) => void;
|
||||
export interface WritableComputedInjectOptions<T, K> {
|
||||
get: ComputedInjectGetter<T, K>
|
||||
set: ComputedInjectSetter<K>
|
||||
get: ComputedInjectGetter<T, K>;
|
||||
set: ComputedInjectSetter<K>;
|
||||
}
|
||||
export interface WritableComputedInjectOptionsWithDefault<T, K> {
|
||||
get: ComputedInjectGetterWithDefault<T, K>
|
||||
set: ComputedInjectSetter<K>
|
||||
get: ComputedInjectGetterWithDefault<T, K>;
|
||||
set: ComputedInjectSetter<K>;
|
||||
}
|
||||
export declare function computedInject<T, K = any>(
|
||||
key: InjectionKey<T> | string,
|
||||
getter: ComputedInjectGetter<T, K>,
|
||||
): ComputedRef<K | undefined>
|
||||
): ComputedRef<K | undefined>;
|
||||
export declare function computedInject<T, K = any>(
|
||||
key: InjectionKey<T> | string,
|
||||
options: WritableComputedInjectOptions<T, K>,
|
||||
): ComputedRef<K | undefined>
|
||||
): ComputedRef<K | undefined>;
|
||||
export declare function computedInject<T, K = any>(
|
||||
key: InjectionKey<T> | string,
|
||||
getter: ComputedInjectGetterWithDefault<T, K>,
|
||||
defaultSource: T,
|
||||
treatDefaultAsFactory?: false,
|
||||
): ComputedRef<K>
|
||||
): ComputedRef<K>;
|
||||
export declare function computedInject<T, K = any>(
|
||||
key: InjectionKey<T> | string,
|
||||
options: WritableComputedInjectOptionsWithDefault<T, K>,
|
||||
defaultSource: T | (() => T),
|
||||
treatDefaultAsFactory: true,
|
||||
): ComputedRef<K>
|
||||
): ComputedRef<K>;
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user