1
0
Fork 0
mirror of synced 2024-07-07 23:35:49 +12:00

Make user data source refreshable in client apps

This commit is contained in:
Andrew Kingston 2021-02-26 14:04:31 +00:00
parent a67a8fb957
commit d27dff0261

View file

@ -11,6 +11,7 @@
screenStore, screenStore,
authStore, authStore,
} from "../store" } from "../store"
import { TableNames, ActionTypes } from "../constants"
// Provide contexts // Provide contexts
setContext("sdk", SDK) setContext("sdk", SDK)
@ -25,10 +26,20 @@
await authStore.actions.fetchUser() await authStore.actions.fetchUser()
loaded = true loaded = true
}) })
// 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: TableNames.USERS } },
},
]
</script> </script>
{#if loaded && $screenStore.activeLayout} {#if loaded && $screenStore.activeLayout}
<Provider key="user" data={$authStore}> <Provider key="user" data={$authStore} {actions}>
<Component definition={$screenStore.activeLayout.props} /> <Component definition={$screenStore.activeLayout.props} />
<NotificationDisplay /> <NotificationDisplay />
</Provider> </Provider>