mirror of https://github.com/vuejs/core.git
feat(reactivity): expose last result for computed getter (#9497)
This commit is contained in:
parent
3c828f3cfb
commit
48b47a1ab6
|
@ -16,8 +16,8 @@ export interface WritableComputedRef<T> extends Ref<T> {
|
||||||
readonly effect: ReactiveEffect<T>
|
readonly effect: ReactiveEffect<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ComputedGetter<T> = (...args: any[]) => T
|
export type ComputedGetter<T> = (oldValue?: T) => T
|
||||||
export type ComputedSetter<T> = (v: T) => void
|
export type ComputedSetter<T> = (newValue: T) => void
|
||||||
|
|
||||||
export interface WritableComputedOptions<T> {
|
export interface WritableComputedOptions<T> {
|
||||||
get: ComputedGetter<T>
|
get: ComputedGetter<T>
|
||||||
|
@ -41,9 +41,10 @@ export class ComputedRefImpl<T> {
|
||||||
isReadonly: boolean,
|
isReadonly: boolean,
|
||||||
isSSR: boolean
|
isSSR: boolean
|
||||||
) {
|
) {
|
||||||
this.effect = new ReactiveEffect(getter, () => {
|
this.effect = new ReactiveEffect(
|
||||||
triggerRefValue(this, DirtyLevels.ComputedValueMaybeDirty)
|
() => getter(this._value),
|
||||||
})
|
() => triggerRefValue(this, DirtyLevels.ComputedValueMaybeDirty)
|
||||||
|
)
|
||||||
this.effect.computed = this
|
this.effect.computed = this
|
||||||
this.effect.active = this._cacheable = !isSSR
|
this.effect.active = this._cacheable = !isSSR
|
||||||
this[ReactiveFlags.IS_READONLY] = isReadonly
|
this[ReactiveFlags.IS_READONLY] = isReadonly
|
||||||
|
|
Loading…
Reference in New Issue