Lime Web Components API Documentation - v6.27.0
    Preparing search index...

    Interface TaskRepository

    Service for creating background tasks

    interface TaskRepository {
        create(
            url: string,
            data: any,
            cancelAction?: boolean,
            message?: string,
        ): Promise<string | void>;
        getStatus(ids: string[]): Promise<TaskStatus[]>;
        subscribe(
            callback: (...args: unknown[]) => void,
            options?: StateOptions,
        ): () => void;
    }

    Hierarchy (View Summary)

    Index

    Methods

    • Create a new background task

      Parameters

      • url: string

        url to the resource that will create the task

      • data: any

        task specific data

      • OptionalcancelAction: boolean

        true to allow task creation to be cancelled

      • Optionalmessage: string

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

      Returns Promise<string | void>

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

    • Get status about specific tasks

      Parameters

      • ids: string[]

        the ids of the tasks to check

      Returns Promise<TaskStatus[]>

      a promise that resolves to the status about the tasks

    • 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.

      Parameters

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

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

      • Optionaloptions: StateOptions

        Optional transformations and filters for the subscription

      Returns () => void

      Unsubscribe function - call this to stop receiving updates

      • 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
      // 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] }
      );