Skip to content

Instantly share code, notes, and snippets.

@TheLucifurry
Last active March 29, 2024 11:22
Show Gist options
  • Select an option

  • Save TheLucifurry/5e78974cd87c65d8645558989606c2f1 to your computer and use it in GitHub Desktop.

Select an option

Save TheLucifurry/5e78974cd87c65d8645558989606c2f1 to your computer and use it in GitHub Desktop.
import { ref } from 'vue'
/**
* Creates a reactive Set
* Allows access without using ".value",
* unlike the direct declaration of `ref(new Set())`,
* while retaining reactivity when using its methods
*/
export function useSet<T>(...args: ConstructorParameters<typeof Set<T>>) {
return ref(new Set<T>(...args)).value as Set<T>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment