Service for creating background tasks

Hierarchy

Methods

  • Create a new background task

    Returns

    a promise that resolves to the id of the task if it was created successfully

    Parameters

    • url: string

      url to the resource that will create the task

    • data: any

      task specific data

    • Optional cancelAction: boolean

      true to allow task creation to be cancelled

    • Optional message: string

      notification message to display before the task is created instead of the default one

    Returns Promise<string | void>

  • Get status about specific tasks

    Returns

    a promise that resolves to the status about the tasks

    Parameters

    • ids: string[]

      the ids of the tasks to check

    Returns Promise<TaskStatus[]>

  • Subscribe to state changes with optional transformation and filtering.

    The subscription will immediately invoke the callback with the current state (if any), then continue to call it whenever the state changes. The map and filter options allow you to transform and selectively receive updates.

    Returns

    Unsubscribe function - call this to stop receiving updates

    Remarks

    • Map functions are applied sequentially to transform the state
    • Filter functions must all return true for the callback to be invoked
    • Functions in map/filter arrays are bound to the component instance
    • Always store and call the unsubscribe function when component is destroyed

    Example

    // Basic subscription
    const unsubscribe = repository.subscribe((state) => {
    console.log('State updated:', state);
    });

    // With transformations
    const unsubscribe = repository.subscribe(
    (userName) => console.log('User:', userName),
    { map: [(state) => state.user?.name] }
    );

    Parameters

    • callback: ((...args: unknown[]) => void)

      Function called with state updates (after map/filter applied)

        • (...args: unknown[]): void
        • Parameters

          • Rest ...args: unknown[]

          Returns void

    • Optional options: StateOptions

      Optional transformations and filters for the subscription

    Returns (() => void)

      • (): void
      • Subscribe to state changes with optional transformation and filtering.

        The subscription will immediately invoke the callback with the current state (if any), then continue to call it whenever the state changes. The map and filter options allow you to transform and selectively receive updates.

        Returns

        Unsubscribe function - call this to stop receiving updates

        Remarks

        • Map functions are applied sequentially to transform the state
        • Filter functions must all return true for the callback to be invoked
        • Functions in map/filter arrays are bound to the component instance
        • Always store and call the unsubscribe function when component is destroyed

        Example

        // Basic subscription
        const unsubscribe = repository.subscribe((state) => {
        console.log('State updated:', state);
        });

        // With transformations
        const unsubscribe = repository.subscribe(
        (userName) => console.log('User:', userName),
        { map: [(state) => state.user?.name] }
        );

        Returns void