feat: shared loading state + cleanup loading state management (#5835)
* feat: implement shared loading bar component and polished loading states across the app * feat: align loading states + ensureQueryData changes * fix: lint + bugs * fix: skeleton for manage servers page * fix: merge conflict fix
This commit is contained in:
27
packages/ui/src/providers/loading-state.ts
Normal file
27
packages/ui/src/providers/loading-state.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { Ref } from 'vue'
|
||||
|
||||
import { createContext } from './create-context'
|
||||
|
||||
/**
|
||||
* Cross-platform loading-state contract injected by the host app.
|
||||
* Consumed by the shared `LoadingBar` and `ReadyTransition` components.
|
||||
*/
|
||||
export interface LoadingStateProvider {
|
||||
/** True iff at least one active load token is registered. */
|
||||
readonly pending: Readonly<Ref<boolean>>
|
||||
/** Host-level kill switch (e.g. disable the bar during a splash screen). */
|
||||
readonly barEnabled: Readonly<Ref<boolean>>
|
||||
/** Begin a tracked load. Returns a unique token; pair with `end(token)`. */
|
||||
begin(): symbol
|
||||
/** End a previously-begun load. Idempotent — unknown or repeat tokens are silently ignored. */
|
||||
end(token: symbol): void
|
||||
/** Fire a synthetic load that auto-releases after `durationMs` (default 500ms). For manual-refresh buttons. */
|
||||
beginManual(durationMs?: number): void
|
||||
/** Toggle the bar at the host level. */
|
||||
setEnabled(enabled: boolean): void
|
||||
}
|
||||
|
||||
export const [injectLoadingState, provideLoadingState] = createContext<LoadingStateProvider>(
|
||||
'root',
|
||||
'loadingState',
|
||||
)
|
||||
Reference in New Issue
Block a user