Hi, I am writing a front end plugin where I need the application object (app: JupyterFrontEnd
) in a certain function. Currently, I am defining the function as a closure inside my activate
function:
const plugin: JupyterFrontEndPlugin<void> = {
id: 'myfancy:plugin'
// ...
activate: (
app: JupyterFrontEnd,
toolbarRegistry: IToolbarWidgetRegistry | null,
// ...
) => {
const createStatusWidget = (panel: NotebookPanel) => {
// do something with app in here
}
toolbarRegistry.registerFactory<NotebookPanel>(
'Notebook', 'mydemo', createStatusWidget
);
}
}
Is there a way to get app
from somewhere else, for example from the NotebookPanel
object or from a global function? Then I could factor functions like this out of my activate method.
I guess I could add a parameter app
to createStatusWidget, and then use small lambda, but maybe there is a simpler solution:
toolbarRegistry.registerFactory<NotebookPanel>(
'Notebook', 'mydemo', panel => createStatusWidget2(app, panel)
);