Callback function of ILabShell is never read

Hello Guys,

I am designing my own home page instead of using the launcher extension.
My activate function is like following:

function activate(app: JupyterFrontEnd,
                  palette: ICommandPalette,
                  labShell: ILabShell,
                  restorer: ILayoutRestorer | null) {
  console.log('JupyterLab extension homepage is activated!');
  // Declare a widget variable
  let widget: MainAreaWidget<myWidget>;

  // Add an application command
  const command: string = 'launcher:create';
  app.commands.addCommand(command, {
    label: 'my Homepage',
    execute: () => {

      const content = new myWidget();
      widget = new MainAreaWidget({content});
      widget.id = 'home';
      widget.title.label = 'Home';
      widget.title.closable = true;

      const callback = (item: Widget) => {
        labShell.add(item, 'main');
      };

      app.shell.add(widget, 'main');
      app.shell.activateById(widget.id);

      labShell.layoutModified.connect(() => {
        // If there is only a launcher open, remove the close icon.
        widget.title.closable = toArray(app.shell.widgets('main')).length > 1;
      }, widget);
    category: ('my')
  });
}

And i got this error about the callback function is never be used.

src/index.ts:79:13 - error TS6133: ‘callback’ is declared but its value is never read.

79 const callback = (item: Widget) => {
~~~~~~~~

Found 1 error in src/index.ts:7

Wellcome :wave: The error is technically correct - you are declaring the callback function but not using it anywhere (there is no callback() invocation, nor is it passed to any other function). If you do not want to use it you need to delete it (or comment it out). What is your intention? What do you want your code to do?

Hello Krassowski,

Thanks a lot for your reponse!

I wrote my own Widget like following:

class myWidget extends Widget {
    /**
    * Construct a new widget.
    */
    constructor() {
      super();

      this.addClass('my-apodWidget');

      this.node.innerHTML = `

        <div class="container">
            <h1>my lab</h1>
            <p class="subtitle">xxx</p>
        </div>

        <div class="button-container">
            <button data-commandLinker-command="nbgrader:open-assignment-list" class="button">
                <div class="icon"></div>
                <span>start projects</span>
            </button>
        </div>
          `;

    }
}

As you can see, I have a button here in my Widget. And i can link the button click event to a Command in pallete. But I also want to write a callback function for the button click event. The Function will then read a json file and show a Dialog, when User click on the Button.

But i find it is difficult to realize. Cloud you please help me to get little further?