Skip to content

Instantly share code, notes, and snippets.

@ycmjason
Created February 26, 2020 16:26
Show Gist options
  • Save ycmjason/1f91cb51db6c214f70c0052f1c430458 to your computer and use it in GitHub Desktop.
Save ycmjason/1f91cb51db6c214f70c0052f1c430458 to your computer and use it in GitHub Desktop.
const computed = <T>(fn: () => T): Ref<T> => {
const r = ref<T>(undefined as any)
watch(() => {
r.value = fn()
})
return r
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment