1
0
Fork 0
mirror of synced 2024-09-28 07:11:40 +12:00
budibase/packages/client/src/components/context/UserBindingsProvider.svelte

23 lines
614 B
Svelte
Raw Normal View History

<script>
import Provider from "./Provider.svelte"
import { authStore } from "stores"
import { ActionTypes } from "constants"
import { Constants } from "@budibase/frontend-core"
// Register this as a refreshable datasource so that user changes cause
// the user object to be refreshed
$: actions = [
{
type: ActionTypes.RefreshDatasource,
callback: () => authStore.actions.fetchUser(),
metadata: {
dataSource: { type: "table", tableId: Constants.TableNames.USERS },
},
},
]
</script>
<Provider key="user" data={$authStore} {actions}>
<slot />
</Provider>