new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Vue · all subjects

computed properties

6 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

computed() creates readonly reactive ref from getter function

computed() takes a getter function and returns a readonly reactive ref object for the returned value from the getter. It can also take an object with get and set functions to create a writable ref object. A readonly computed property cannot be assigned to (attempting to do so will cause an error). A writable computed property has both get and set functions.

computed() function signature - read-only

function computed<T>( getter: (oldValue: T | undefined) => T, debuggerOptions?: DebuggerOptions ): Readonly<Ref<Readonly<T>>>

computed() function signature - writable

function computed<T>( options: { get: (oldValue: T | undefined) => T set: (value: T) => void }, debuggerOptions?: DebuggerOptions ): Ref<T>

computed() readonly example

const count = ref(1) const plusOne = computed(() => count.value + 1) console.log(plusOne.value) // 2 plusOne.value++ // error

computed() writable example

const count = ref(1) const plusOne = computed({ get: () => count.value + 1, set: (val) => { count.value = val - 1 } }) plusOne.value = 1 console.log(count.value) // 0

computed() debugging example

const plusOne = computed(() => count.value + 1, { onTrack(e) { debugger }, onTrigger(e) { debugger } })

Give your agent this brain