Browse Source

feat(gui-v2): add watch options as arg to useViews

pull/2837/head
braks 2 years ago
parent
commit
1ec9a62fdc
  1. 8
      packages/nc-gui-v2/composables/useViews.ts

8
packages/nc-gui-v2/composables/useViews.ts

@ -1,8 +1,9 @@
import type { FormType, GalleryType, GridType, KanbanType, TableType } from 'nocodb-sdk' import type { FormType, GalleryType, GridType, KanbanType, TableType } from 'nocodb-sdk'
import type { MaybeRef } from '@vueuse/core' import type { MaybeRef } from '@vueuse/core'
import type { WatchOptions } from '@vue/runtime-core'
import { useNuxtApp } from '#app' import { useNuxtApp } from '#app'
export default function (meta: MaybeRef<TableType | undefined>) { export default function (meta: MaybeRef<TableType | undefined>, watchOptions: WatchOptions = {}) {
let views = $ref<(GridType | FormType | KanbanType | GalleryType)[]>([]) let views = $ref<(GridType | FormType | KanbanType | GalleryType)[]>([])
const { $api } = useNuxtApp() const { $api } = useNuxtApp()
@ -17,7 +18,10 @@ export default function (meta: MaybeRef<TableType | undefined>) {
} }
} }
watch(() => meta, loadViews, { immediate: true }) watch(() => meta, loadViews, {
immediate: true,
...watchOptions,
})
return { views: $$(views), loadViews } return { views: $$(views), loadViews }
} }

Loading…
Cancel
Save