Theia API Documentation v1.65.0
    Preparing search index...

    Service to log and categorize messages, show progress information and offer actions.

    The messages are processed by this service and forwarded to an injected MessageClient. For example "@theia/messages" provides such a client, rendering messages as notifications in the frontend.

      @inject(MessageService)
    protected readonly messageService: MessageService;

    messageService.warn("Typings not available");

    messageService.error("Could not restore state", ["Rollback", "Ignore"])
    .then(action => action === "Rollback" && rollback());
    Index

    Constructors

    Properties

    Methods

    • Logs the message as "error" and, if given, offers actions to act on it.

      Type Parameters

      • T extends string

      Parameters

      • message: string

        the message to log.

      • ...actions: T[]

        the actions to offer. Can be omitted.

      Returns Promise<undefined | T>

      the selected action if there is any, undefined when there was no action or none was selected.

    • Logs the message as "error" and, if given, offers actions to act on it.

      Type Parameters

      • T extends string

      Parameters

      • message: string

        the message to log.

      • Optionaloptions: MessageOptions

        additional options. Can be omitted

      • ...actions: T[]

        the actions to offer. Can be omitted.

      Returns Promise<undefined | T>

      the selected action if there is any, undefined when there was no action or none was selected.

    • Logs the message as "info" and, if given, offers actions to act on it.

      Type Parameters

      • T extends string

      Parameters

      • message: string

        the message to log.

      • ...actions: T[]

        the actions to offer. Can be omitted.

      Returns Promise<undefined | T>

      the selected action if there is any, undefined when there was no action or none was selected.

    • Logs the message as "info" and, if given, offers actions to act on it.

      Type Parameters

      • T extends string

      Parameters

      • message: string

        the message to log.

      • Optionaloptions: MessageOptions

        additional options. Can be omitted

      • ...actions: T[]

        the actions to offer. Can be omitted.

      Returns Promise<undefined | T>

      the selected action if there is any, undefined when there was no action or none was selected.

    • Logs the message and, if given, offers actions to act on it.

      Type Parameters

      • T extends string

      Parameters

      • message: string

        the message to log.

      • ...actions: T[]

        the actions to offer. Can be omitted.

      Returns Promise<undefined | T>

      the selected action if there is any, undefined when there was no action or none was selected.

    • Logs the message and, if given, offers actions to act on it.

      Type Parameters

      • T extends string

      Parameters

      • message: string

        the message to log.

      • Optionaloptions: MessageOptions

        additional options. Can be omitted

      • ...actions: T[]

        the actions to offer. Can be omitted.

      Returns Promise<undefined | T>

      the selected action if there is any, undefined when there was no action or none was selected.

    • Shows the given message as a progress.

      Parameters

      • message: ProgressMessage

        the message to show for the progress.

      • OptionalonDidCancel: () => void

        an optional callback which will be invoked if the progress indicator was canceled.

      Returns Promise<Progress>

      a promise resolving to a Progress object with which the progress can be updated.

        @inject(MessageService)
      protected readonly messageService: MessageService;

      // this will show "Progress" as a cancelable message
      this.messageService.showProgress({text: 'Progress'});

      // this will show "Rolling back" with "Cancel" and an additional "Skip" action
      this.messageService.showProgress({
      text: `Rolling back`,
      actions: ["Skip"],
      },
      () => console.log("canceled"))
      .then((progress) => {
      // register if interested in the result (only necessary for custom actions)
      progress.result.then((result) => {
      // will be 'Cancel', 'Skip' or `undefined`
      console.log("result is", result);
      });
      progress.report({message: "Cleaning references", work: {done: 10, total: 100}});
      progress.report({message: "Restoring previous state", work: {done: 80, total: 100}});
      progress.report({message: "Complete", work: {done: 100, total: 100}});
      // we are done so we can cancel the progress message, note that this will also invoke `onDidCancel`
      progress.cancel();
      });
    • Logs the message as "warning" and, if given, offers actions to act on it.

      Type Parameters

      • T extends string

      Parameters

      • message: string

        the message to log.

      • ...actions: T[]

        the actions to offer. Can be omitted.

      Returns Promise<undefined | T>

      the selected action if there is any, undefined when there was no action or none was selected.

    • Logs the message as "warning" and, if given, offers actions to act on it.

      Type Parameters

      • T extends string

      Parameters

      • message: string

        the message to log.

      • Optionaloptions: MessageOptions

        additional options. Can be omitted

      • ...actions: T[]

        the actions to offer. Can be omitted.

      Returns Promise<undefined | T>

      the selected action if there is any, undefined when there was no action or none was selected.