Skip to main content
Version: 1.0.1

setLoading

@spartanfx/react v1.0.1


@spartanfx/react / setLoading

Function: setLoading()

setLoading(message): void

Imperative API to show (or update) the global loading overlay.

Parameters

message

string = DEFAULT_MESSAGE

Optional message to display in the overlay.

Returns

void

void

Remarks

  • If this is the first active loader (activeLoaders is 0), it initializes a Notiflix "pulse" overlay with configured options.
  • If one or more loaders are already active, this updates the displayed message instead.
  • Each call increments the internal activeLoaders counter; consumers must pair each call with a corresponding removeLoading to avoid leaking the overlay.

Example

// Show a loader imperatively during an async task
setLoading('Saving changes…');
try {
await save();
} finally {
removeLoading();
}