Skip to main content

Overview

useWorkspaceListActions provides the low-level fetch, create, and delete operations used internally by useWorkspaceList. In most cases you should use useWorkspaceList directly, which wraps these actions with filter state, debouncing and load-more. Use this hook only when you need direct control over fetching a list’s pages.

Usage Example

Methods

(listId: string, params: FetchWorkspacesOptions) => Promise<Workspace[] | null>
Fetch one page for the given list and store it in Redux state: page 1 replaces the list, a later page is appended. params takes page and limit (both required) and the optional filters relation, parentWorkspaceId, sortDir and include (an array). A filter that is null or left out isn’t sent, so the server’s default applies. Throws on a failed request, after recording the error on the list.
(listId: string, props: CreateWorkspaceOptions) => Promise<Workspace | undefined>
Create a workspace (name, optional metadata and parentWorkspaceId), read it back with the optional include flags so it carries reasons, and add it to the given list where the server would list it — see createWorkspace on useWorkspaceList. If the read-back fails, the workspace the create returned is added, without reasons. Throws if the create fails.
(listId: string, props: { workspaceId: string }) => Promise<void>
Delete a workspace and remove it from the given list’s state. Throws on a failed request, leaving the list as it was.
Prefer useWorkspaceList for most use cases — it handles filter state, pagination, debouncing and load-more.