Skip to content

Commit

Permalink
feat(add): api computed
Browse files Browse the repository at this point in the history
  • Loading branch information
gcclll committed Jan 21, 2021
1 parent 111fe04 commit 179d6f6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/runtime-core/src/apiComputed.ts
@@ -0,0 +1,20 @@
import {
computed as _computed,
ComputedGetter,
ComputedRef,
WritableComputedOptions,
WritableComputedRef
} from '@vue/reactivity'
import { recordInstanceBoundEffect } from './component'

export function computed<T>(getter: ComputedGetter<T>): ComputedRef<T>
export function computed<T>(
options: WritableComputedOptions<T>
): WritableComputedRef<T>
export function computed<T>(
getterOrOptions: ComputedGetter<T> | WritableComputedOptions<T>
) {
const c = _computed(getterOrOptions as any)
recordInstanceBoundEffect(c.effect)
return c
}
1 change: 1 addition & 0 deletions packages/runtime-core/src/index.ts
Expand Up @@ -35,6 +35,7 @@ export {
flushPostFlushCbs,
invalidateJob
} from './scheduler'
export { provide, inject } from './apiInject'
export { defineComponent } from './apiDefineComponent'

// Advanced API ----------------------------------------------------------------
Expand Down

0 comments on commit 179d6f6

Please sign in to comment.