Skip to content

Instantly share code, notes, and snippets.

@TheLucifurry
Last active March 29, 2024 11:22
Show Gist options
  • Save TheLucifurry/8e6c6b0ec6187ead3686b15cf932086b to your computer and use it in GitHub Desktop.
Save TheLucifurry/8e6c6b0ec6187ead3686b15cf932086b to your computer and use it in GitHub Desktop.
import { ref } from 'vue'
/**
* Creates a reactive Map
* Allows access without using ".value",
* as opposed to directly declaring `ref(new Map())`,
* while retaining reactivity when using its methods
*/
export function useMap<K, V>(...args: ConstructorParameters<typeof Map<K, V>>) {
return ref(new Map<K, V>(...args)).value as Map<K, V>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment