コンテンツへスキップ

createSharedComposable

カテゴリ
エクスポートサイズ
213 B
最終更新
先週
関連

複数の Vue インスタンスで使用可能なコンポーザブル関数を作成します。

使い方

ts
import { createSharedComposable, useMouse } from '@vueuse/core'

const useSharedMouse = createSharedComposable(useMouse)

// CompA.vue
const { x, y } = useSharedMouse()

// CompB.vue - will reuse the previous state and no new event listeners will be registered
const { x, y } = useSharedMouse()

型宣言

typescript
/**
 * Make a composable function usable with multiple Vue instances.
 *
 * @see https://vueuse.dokyumento.jp/createSharedComposable
 */
export declare function createSharedComposable<Fn extends AnyFn>(
  composable: Fn,
): Fn

ソース

ソースドキュメント

コントリビューター

Anthony Fu
Anthony Fu
XinXiao
童欧巴
Egor Kotlyarov

変更履歴

v12.0.0-beta.1 2024/11/21
0a9ed - feat!: Vue 2 のサポートを削除、バンドルを最適化し、クリーンアップしました (#4349)
v11.0.2 2024/08/24
a2441 - fix: コンポーザブル関数の戻り値が空の場合を処理します (#4151)

MITライセンスの下でリリースされています。