Replies: 15 comments 29 replies
-
Discussionwith major update all composables should return an object, even if they have only one return value currently: const { focused } = useFocusWithin(target)
// vs
const focused = useWindowFocus() idea: const { focused } = useFocusWithin(target)
// vs
const { focused } = useWindowFocus() excluding things like Pros:
Cons:
|
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
DiscussionMost returned refs should be readonly i.e. const { width, height } = useWindowSize() |
Beta Was this translation helpful? Give feedback.
-
DiscussionReplace most primitive |
Beta Was this translation helpful? Give feedback.
-
DiscussionFor the parameters or options, should we consistently use |
Beta Was this translation helpful? Give feedback.
-
I am not sure if twoslash helps? To make some types shows on hover only. |
Beta Was this translation helpful? Give feedback.
-
Some of the usage document are using While implementing Twoslash (Draft PR: #4560), I will also take the opportunity to convert all the doc pages to use |
Beta Was this translation helpful? Give feedback.
-
DiscussionComposables that wrap Browser/MDN APIs should be named Like This will mean that any composable that wraps part of a browser API should always introduce the `use' composable to wrap it. I think this will help with visibility and consistency. If I am looking for a resize observer I will find it, we can link to useElementSize as related. This will also benefit future composables that wrap other parts of this API. Related PRs:
|
Beta Was this translation helpful? Give feedback.
-
DiscussionReplace |
Beta Was this translation helpful? Give feedback.
-
Discussionrelated to #4548 (comment) We should rethink I think we should double down on one option. First of all, its kinda unexpected to export some Option 1: Only and always use the explicit type, if possible.Pros:
Cons:
Option 2: always either
|
Beta Was this translation helpful? Give feedback.
-
DiscussionAll Some behave more like a composable (like Let us cover some non-controversial parts first:
Now for a controversial thought:
Example how a drop-in could look: const debounced = refDebounced(32)
debounced.value = 53
console.log(debounced.value) // still 32
// wait 200 ms
console.log(debounced.value) // now 53 |
Beta Was this translation helpful? Give feedback.
-
DiscussionDefault/initial values. Currently we have some inconsistent behaviour with initial values when passed to a composable. Scenario 1:
|
accepts raw value | accepts writeable ref | accepts computed(()=>/* */) |
accepts getter fn | Comment | |
---|---|---|---|---|---|
Scenario 1 | ✅ | 🔴 | 🔴 | 🔴 | |
Scenario 2 | ✅ | ✅ | ✅ | ✅ | changing defaults does not effect data (without additional logic) |
Scenario 3 | ✅ | ✅ | 🔴 (internal write breaks composable) | 🔴 (.value is the function) | changing internal value changes default if writeable |
Scenario 3.5 | ✅ | ✅ | 🔴 | ✅ (no reactive updates) | chaning the internal value does change default if writeable |
IMO
- we should try to always accept reactive (all replace scenario 1)
- I think if we want to keep the idea of 3.5 we can do
const data = shallowRef(isReadonly(initialValue) ? toValue(initialValue) : initialValue)
- maybe we want that in some scenario 3 too? - If possible we should commit to one scenario only, if we cannot commit to one scenario, maybe we can have a naming convention or something to tell if we have scenario 2 or 3. like calling scenario 2 "initialXyzValue" and 3 "defaultXyzValue".
- sometimes users (including me) are confused with default changing when internal value changes + when the default value cant be computed (scenario 3)
Beta Was this translation helpful? Give feedback.
-
DiscussionAll composables that accept a This type is being used to denote composables that react to the refs/getters changing their values, but also as a helper to skip users the need to write Pros:
Cons:
|
Beta Was this translation helpful? Give feedback.
-
DiscussionAll composables that use Right now, the Pros:
Cons:
|
Beta Was this translation helpful? Give feedback.
-
replace WatchStopHandle with WatchHandle in watchAtMost, watchDebounced, watchIgnorable, watchTriggerable, and watchWithFilter for consistency and improved functionality reference to the watch handler source code: https://github.com/vuejs/core/blob/main/packages/reactivity/src/watch.ts#L214 https://github.com/vuejs/core/blob/main/packages/reactivity/src/watch.ts#L324 If constrain it according to the return value of the 'WatchHandle' type, it should not cause breaking changes |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Note
WIP
IMO
overall
toRef(initialvalue)
sometimesref(toValue(initialValue))
core
computedAsync
computedInject
createReusableTemplate
createUnrefFn
createUnrefFn
onClickOutside
onElementRemoval
onKeyStroke
onLongPress
templateRef
unrefElement
useActiveElement
useAnimate
useAsyncQueue
useAsyncState
useBase64
useEncodeBase64
anduseDecodeBase64
useBattery
useBluetooth
useBreakpoints
useBroadcastChannel
useBroadcastChannel(options: {name: string, /*...*/)
->useBroadcastChannel(name, options)
+ some returns are not readonlyuseBrowserLocation
useClipboard
useClipboardItems
useCloned
isModified
can be readonlyuseColorMode
return Object.assign(auto, { store, system, state })
👀useConfirmDialog
useCountdown
useCssVar
useCurrentElement
useCycleList
useDark
useDebouncedRefHistory
useDeviceMotion
useDeviceOrientation
useDevicePixelRatio
useDevicesList
useDisplayMedia
useDocumentVisibility
useDraggable
useDropZone
useElementBouding
useElementByPoint
useElementHover
useElementSize
useElementVisibility
useEventBus
useEventListener
useEventSource
useEyeDropper
useFavicon
useFetch
useFileDialog
useFileSystemAccess
useFocus
useFocusWithin
useFps
useFullscreen
useGamepad
useGeolocation
useIdle
useImage
useInfiniteScroll
useIntersectionObserver
useKeyModifier
useLocalStorage
useMagicKeys
useManualRefHistory
useMediaControls
useMediaQuery
useMemoize
useMemory
useMounted
useMouse
useMouseInElement
useMousePressed
useMutationObserver
useNavigatorLanguage
useNetwork
useNow
useObjectUrl
useOffsetPagination
useOnline
usePageLeave
useParallax
useParentElement
usePerformanceObserver
usePermission
usePointer
usePointerLock
usePointerSwipe
usePreferredColorScheme
usePreferredContrast
usePreferredDark
usePreferredLanguages
usePreferredReducedMotion
usePreferredReducedTransparency
usePrevious
useRafFn
useRefHistory
useResizeObserver
useScreenOrientation
useScreenSafeArea
useScriptTag
useScroll
useScrollLock
useSessionStorage
useShare
useSorted
useSpeechRecognition
useSpeechSynthesis
useSSRWidth
useStepper
useStorage
useStorageAsync
useStyleTag
useSupported
useSwipe
useTemplateRefsList
useTextareaAutosize
useTextDirection
useTextSelection
useWindowTextSelection
useThrottledRefHistory
useTimeAgo
useTimeoutPoll
useTimestamp
useTitle
useTransition
useUrlSearchParams
useUserMedia
useVibrate
useVirtualList
useVModel
useVModels
useWakeLock
useWebNotification
requestPermissions
default istrue
useWebSocket
useWebWorker
useWebWorkerFn
useWindowFocus
useWindowSize
shared
computedEager
computedWithControl
createEventHook
createGlobalState
createInjectionState
createSharedComposable
extendRef
get
extendRef
injectLocal
isDefined
makeDestructurable
provideLocal
reactify
reactifyObject
reactiveComputed
reactiveOmit
reactivePick
refAutoReset
refDebounced
refDefault
refThrottled
refWithControl
set
syncRef
syncRefs
toReactive
reactive(ref)
?toRef
toRefs
toValue
tryOnBeforeMount
tryOnBeforeUnmount
tryOnMount
tryOnScopeDispose
tryOnUnmounted
until
useArrayDifference
useArrayEvery
useArrayFilter
useArrayFind
useArrayFindLast
useArrayJoin
useArrayMap
useArrayReduce
useArraySome
useArrayUnique
useCounter
toValue
hereuseDateFormat
Intl.DateTimeFormat
useDebounceFn
useInterval
useIntervalFn
useLastChanged
useThrottleFn
useTimeout
useTimeoutFn
useToNumber
useToString
useToggle
watchArray
watchAtMost
watchDebounced
watchDeep
watchIgnorable
watchImmediate
watchOnce
watchPausable
watchThrottled
watchTriggerable
watchWithFilter
whenever
docs
ReturnType<useXYZ>
Beta Was this translation helpful? Give feedback.
All reactions