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

Nuxt · API · all subjects

composables/use-runtime-hook

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.

useRuntimeHook signature

useRuntimeHook is a composable with the signature: function useRuntimeHook<THookName extends keyof RuntimeNuxtHooks>(name: THookName, fn: RuntimeNuxtHooks[THookName] extends HookCallback ? RuntimeNuxtHooks[THookName] : never): void. It takes a hook name and a callback function, and returns void.

useRuntimeHook parameters

useRuntimeHook accepts two parameters: (1) name - the name of the runtime hook to register, which must be a key of RuntimeNuxtHooks. (2) fn - the callback function to execute when the hook is triggered, with the function signature varying based on the hook name.

useRuntimeHook return value

useRuntimeHook does not return a value. It automatically unregisters the hook when the component scope is destroyed.

useRuntimeHook automatic cleanup

The hook registered with useRuntimeHook is automatically unregistered and will not be called again when the component is unmounted.

useRuntimeHook availability

useRuntimeHook is available in Nuxt v3.14 and later.

useRuntimeHook example with link:prefetch hook

Example of registering a link:prefetch hook: useRuntimeHook('link:prefetch', (link) => { console.log('Prefetching', link) }). This hook runs every time a link is prefetched and is automatically cleaned up when the component is unmounted.

Give your agent this brain