-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.d.ts
50 lines (47 loc) · 1.11 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { VNodeProps } from 'vue'
import { Channels } from '../index.js'
export interface SubscribeProps {
channels: Channels
}
/**
* Component-wrapper that subscribes
* for channels during component initialization
* and unsubscribes on unmount.
*
* It watches for `channels` changes
* and `isSubscribing` indicates loading state.
*
* ```html
* <template>
* <subscribe :channels="channels" v-slot="{ isSubscribing }">
* <h1 v-if="isSubscribing">Loading</h1>
* <h1 v-else>{{ user.name }}</h1>
* </subscribe>
* </template>
*
* <script>
* import { toRefs, computed } from 'vue'
* import { useStore, Subscribe } from '@logux/vuex'
*
* export default {
* components: { Subscribe },
* props: ['userId'],
* setup (props) {
* let store = useStore()
* let { userId } = toRefs(props)
*
* let user = computed(() => store.state.users[userId.value])
* let channels = computed(() => [`users/${userId.value}`])
*
* return {
* user,
* channels
* }
* }
* }
* </script>
* ```
*/
export const Subscribe: new () => {
$props: VNodeProps & SubscribeProps
}