refactor(reactivity): reuse computed getter check (#4623)
This commit is contained in:
parent
5addef8ecd
commit
b264551c9b
@ -78,7 +78,8 @@ export function computed<T>(
|
||||
let getter: ComputedGetter<T>
|
||||
let setter: ComputedSetter<T>
|
||||
|
||||
if (isFunction(getterOrOptions)) {
|
||||
const onlyGetter = isFunction(getterOrOptions)
|
||||
if (onlyGetter) {
|
||||
getter = getterOrOptions
|
||||
setter = __DEV__
|
||||
? () => {
|
||||
@ -90,11 +91,7 @@ export function computed<T>(
|
||||
setter = getterOrOptions.set
|
||||
}
|
||||
|
||||
const cRef = new ComputedRefImpl(
|
||||
getter,
|
||||
setter,
|
||||
isFunction(getterOrOptions) || !getterOrOptions.set
|
||||
)
|
||||
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter)
|
||||
|
||||
if (__DEV__ && debugOptions) {
|
||||
cRef.effect.onTrack = debugOptions.onTrack
|
||||
|
Loading…
Reference in New Issue
Block a user