refactor: move writable check out of computed setter (#112)

This commit is contained in:
扩散性百万甜面包 2019-10-06 03:48:05 +08:00 committed by Evan You
parent 0bdee72e17
commit caa9297da6

View File

@ -28,7 +28,9 @@ export function computed<T>(
? (getterOrOptions as (() => T))
: (getterOrOptions as WritableComputedOptions<T>).get
const setter = isReadonly
? null
? () => {
// TODO warn attempting to mutate readonly computed value
}
: (getterOrOptions as WritableComputedOptions<T>).set
let dirty: boolean = true
@ -57,12 +59,8 @@ export function computed<T>(
trackChildRun(runner)
return value
},
set value(newValue) {
if (setter) {
set value(newValue: T) {
setter(newValue)
} else {
// TODO warn attempting to mutate readonly computed value
}
}
}
}