35 lines
911 B
Markdown
35 lines
911 B
Markdown
# User
|
|
|
|
Syncs user info data with redis backend.
|
|
|
|
```typescript
|
|
// Create the selection hook using the factory
|
|
const useContextSelection = createContextHook<ClientSelection>({
|
|
endpoint: "/context/dash/selection",
|
|
contextName: "selection",
|
|
enablePeriodicRefresh: false,
|
|
});
|
|
|
|
// Custom hook for selection data with the expected interface
|
|
interface UseSelectionResult {
|
|
selectionData: ClientSelection | null;
|
|
isLoading: boolean;
|
|
error: string | null;
|
|
refreshSelection: () => Promise<void>;
|
|
updateSelection: (newSelection: ClientSelection) => Promise<boolean>;
|
|
}
|
|
|
|
// Wrapper hook that adapts the generic hook to the expected interface
|
|
export function useSelection(): UseSelectionResult {
|
|
const { data, isLoading, error, refresh, update } = useContextSelection();
|
|
|
|
return {
|
|
selectionData: data,
|
|
isLoading,
|
|
error,
|
|
refreshSelection: refresh,
|
|
updateSelection: update,
|
|
};
|
|
}
|
|
```
|