Options
All
  • Public
  • Public/Protected
  • All
Menu

Create a task from the given set of variables and make it runnable.

Type parameters

Hierarchy

Index

Constructors

Properties

closed: boolean
hasError: boolean
deprecated

Internal implementation detail, do not use directly. Will be made internal in v8.

id: string

Unique id per task, randomly generated in the uuid v4 format

initialTitle?: string

Untouched unchanged title of the task

isStopped: boolean
deprecated

Internal implementation detail, do not use directly. Will be made internal in v8.

listr: Listr<Ctx, any, any>
message: { duration?: number; error?: string; retry?: { count: number; withError?: any }; rollback?: string; skip?: string }

A channel for messages.

This requires a separate channel for messages like error, skip or runtime messages to further utilize in the renderers.

Type declaration

  • Optional duration?: number

    Run time of the task, if it has been successfully resolved.

  • Optional error?: string

    Error message of the task, if it has been failed.

  • Optional retry?: { count: number; withError?: any }

    Retry messages

    • count: number
    • Optional withError?: any
  • Optional rollback?: string

    Rollback message of the task, if the rollback finishes

  • Optional skip?: string

    Skip message of the task, if it has been skipped.

observers: Observer<ListrEvent>[]
deprecated

Internal implementation detail, do not use directly. Will be made internal in v8.

operator: undefined | Operator<any, ListrEvent>
deprecated

Internal implementation detail, do not use directly. Will be made internal in v8.

options: ListrOptions<any>
output?: string

Output data from the task.

prompt: undefined | PromptInstance | PromptError
renderHook$: Subject<void>

This will be triggered each time a new render should happen.

rendererOptions: ListrGetRendererOptions<Renderer>
rendererTaskOptions: ListrGetRendererTaskOptions<Renderer>

Per task options for the current renderer of the task.

retry?: { count: number; withError?: any }

Current retry number of the task if retrying

Type declaration

  • count: number
  • Optional withError?: any
skip: string | boolean | ((ctx: Ctx) => string | boolean | Promise<string | boolean>)

Skip current task.

source: undefined | Observable<any>
deprecated

Internal implementation detail, do not use directly. Will be made internal in v8.

state: string

The current state of the task.

subtasks: Task<Ctx, any>[]

Extend current task with multiple subtasks.

task: (ctx: Ctx, task: TaskWrapper<Ctx, Renderer>) => void | ListrTaskResult<Ctx>

Type declaration

tasks: ListrTask<Ctx, any>
thrownError: any
deprecated

Internal implementation detail, do not use directly. Will be made internal in v8.

title?: string

Title of the task

create: (...args: any[]) => any

Type declaration

    • (...args: any[]): any
    • Creates a "subject" by basically gluing an observer to an observable.

      nocollapse
      deprecated

      Recommended you do not use. Will be removed at some point in the future. Plans for replacement still under discussion.

      Parameters

      • Rest ...args: any[]

      Returns any

Accessors

  • set message$(data: { duration?: number; error?: string; retry?: { count: number; withError?: any }; rollback?: string; skip?: string }): void
  • Parameters

    • data: { duration?: number; error?: string; retry?: { count: number; withError?: any }; rollback?: string; skip?: string }
      • Optional duration?: number

        Run time of the task, if it has been successfully resolved.

      • Optional error?: string

        Error message of the task, if it has been failed.

      • Optional retry?: { count: number; withError?: any }

        Retry messages

        • count: number
        • Optional withError?: any
      • Optional rollback?: string

        Rollback message of the task, if the rollback finishes

      • Optional skip?: string

        Skip message of the task, if it has been skipped.

    Returns void

  • get observed(): boolean
  • Returns boolean

  • set output$(data: string): void
  • Parameters

    • data: string

    Returns void

  • Parameters

    Returns void

  • set title$(title: string): void
  • Parameters

    • title: string

    Returns void

Methods

  • Creates a new Observable with this Subject as the source. You can do this to create custom Observer-side logic of the Subject and conceal it from code that uses the Observable.

    Returns Observable<ListrEvent>

    Observable that the Subject casts to

  • check(ctx: Ctx): Promise<void>
  • A function to check whether this task should run at all via enable.

    Parameters

    • ctx: Ctx

    Returns Promise<void>

  • complete(): void
  • Returns void

  • error(err: any): void
  • Parameters

    • err: any

    Returns void

  • forEach(next: (value: ListrEvent) => void): Promise<void>
  • forEach(next: (value: ListrEvent) => void, promiseCtor: PromiseConstructorLike): Promise<void>
  • Used as a NON-CANCELLABLE means of subscribing to an observable, for use with APIs that expect promises, like async/await. You cannot unsubscribe from this.

    WARNING: Only use this with observables you know will complete. If the source observable does not complete, you will end up with a promise that is hung up, and potentially all of the state of an async function hanging out in memory. To avoid this situation, look into adding something like timeout, {@link take}, {@link takeWhile}, or {@link takeUntil} amongst others.

    Example

    import { interval, take } from 'rxjs';

    const source$ = interval(1000).pipe(take(4));

    async function getTotal() {
    let total = 0;

    await source$.forEach(value => {
    total += value;
    console.log('observable -> ' + value);
    });

    return total;
    }

    getTotal().then(
    total => console.log('Total: ' + total)
    );

    // Expected:
    // 'observable -> 0'
    // 'observable -> 1'
    // 'observable -> 2'
    // 'observable -> 3'
    // 'Total: 6'

    Parameters

    Returns Promise<void>

    a promise that either resolves on observable completion or rejects with the handled error

  • deprecated

    Passing a Promise constructor will no longer be available in upcoming versions of RxJS. This is because it adds weight to the library, for very little benefit. If you need this functionality, it is recommended that you either polyfill Promise, or you create an adapter to convert the returned native promise to whatever promise implementation you wanted. Will be removed in v8.

    Parameters

    • next: (value: ListrEvent) => void

      a handler for each value emitted by the observable

    • promiseCtor: PromiseConstructorLike

      a constructor function used to instantiate the Promise

    Returns Promise<void>

    a promise that either resolves on observable completion or rejects with the handled error

  • hasFailed(): boolean
  • Returns whether this task has been failed.

    Returns boolean

  • hasRolledBack(): boolean
  • Returns whether the rollback action was successful.

    Returns boolean

  • hasSubtasks(): boolean
  • Returns whether this task has subtasks.

    Returns boolean

  • hasTitle(): boolean
  • Returns whether this task actually has a title.

    Returns boolean

  • isCompleted(): boolean
  • Returns whether this task has been completed.

    Returns boolean

  • isEnabled(): boolean
  • Returns whether enabled function resolves to true.

    Returns boolean

  • isPending(): boolean
  • Returns whether this task is in progress.

    Returns boolean

  • isPrompt(): boolean
  • Returns whether this task has a prompt inside.

    Returns boolean

  • isRetrying(): boolean
  • Returns whether this task has an actively retrying task going on.

    Returns boolean

  • isRollingBack(): boolean
  • Returns whether this task has an active rollback task going on.

    Returns boolean

  • isSkipped(): boolean
  • Returns whether this task is skipped.

    Returns boolean

  • deprecated

    Internal implementation detail, do not use directly. Will be made internal in v8.

    Type parameters

    • R

    Parameters

    Returns Observable<R>

  • Parameters

    Returns void

  • run(context: Ctx, wrapper: TaskWrapper<Ctx, Renderer>): Promise<void>
  • Run the current task.

    Parameters

    Returns Promise<void>

  • toPromise(): Promise<undefined | ListrEvent>
  • toPromise(PromiseCtor: PromiseConstructor): Promise<undefined | ListrEvent>
  • toPromise(PromiseCtor: PromiseConstructorLike): Promise<undefined | ListrEvent>
  • unsubscribe(): void
  • Returns void