Skip to content

Commit 87266b3

Browse files
committed
feat: autoResult
1 parent c4d9739 commit 87266b3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

demo-app/imports/ui/components/Info.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<script setup>
22
// @ts-nocheck
33
import { Links } from '/imports/api/links/links.js'
4-
import { subscribe, autorun } from 'meteor/vuejs:vue3'
4+
import { subscribe, autoResult } from 'meteor/vuejs:vue3'
55
66
subscribe('links.all')
77
8-
const { result: links } = autorun(() => Links.find({}))
8+
const links = autoResult(() => Links.find({}))
99
1010
function submit (form) {
1111
const title = form.title

packages/vue3/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ export function autorun<TResult = unknown> (callback: () => TResult): AutorunEff
2727
}
2828
}
2929

30+
export function autoResult<TResult = unknown> (callback: () => TResult): ComputedRef<TResult | undefined> {
31+
return autorun(callback).result
32+
}
33+
3034
export function subscribe (name: string, ...args: any[]): Meteor.SubscriptionHandle {
3135
const sub = Meteor.subscribe(name, ...args)
3236
onUnmounted(() => {

0 commit comments

Comments
 (0)