Skip to content

Commit 28ab00e

Browse files
thegoomanjtpio
authored andcommitted
Updated embedded code snippets in readme
1 parent 3731607 commit 28ab00e

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

basics/signals/README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ JupyterLab's Lumino engine uses the `ISignal` interface and the
2121

2222
The basic concept is as follows:
2323

24-
First, a widget (`button.ts`), in this case the one that contains
24+
First, a widget (`button.tsx`), in this case the one that contains
2525
some visual elements such as a button, defines a `_stateChanged` signal:
2626

2727
```ts
@@ -44,7 +44,7 @@ Another widget, in this case the panel (`panel.ts`) that boxes several different
4444
subscribes to the `stateChanged` signal and links some function to it:
4545

4646
```ts
47-
// src/panel.ts#L22-L22
47+
// src/panel.ts#L29-L29
4848

4949
this._widget.stateChanged.connect(this._logMessage, this);
5050
```
@@ -141,13 +141,14 @@ The `panel.ts` class defines an extension panel that displays the
141141
This is done in the constructor.
142142

143143
```ts
144-
// src/panel.ts#L13-L23
144+
// src/panel.ts#L19-L30
145145

146-
constructor() {
147146
super();
147+
this._translator = translator || nullTranslator;
148+
this._trans = this._translator.load('jupyterlab');
148149
this.addClass(PANEL_CLASS);
149150
this.id = 'SignalExamplePanel';
150-
this.title.label = 'Signal Example View';
151+
this.title.label = this._trans.__('Signal Example View');
151152
this.title.closable = true;
152153

153154
this._widget = new ButtonWidget();
@@ -160,7 +161,7 @@ Subscription to a signal is done using the `connect` method of the
160161
`stateChanged` attribute.
161162

162163
```ts
163-
// src/panel.ts#L22-L22
164+
// src/panel.ts#L29-L29
164165

165166
this._widget.stateChanged.connect(this._logMessage, this);
166167
```
@@ -178,7 +179,7 @@ The `_logMessage` function receives as parameters the emitter (of type `ButtonWi
178179
and the count (of type `ICount`) sent by the signal emitter.
179180

180181
```ts
181-
// src/panel.ts#L25-L25
182+
// src/panel.ts#L32-L32
182183

183184
private _logMessage(emitter: ButtonWidget, count: ICount): void {
184185
```
@@ -187,7 +188,7 @@ In our case, that function writes `Button has been clicked ... times.` text
187188
to the browser console and in an alert when the big red button is clicked.
188189
189190
```ts
190-
// src/panel.ts#L25-L29
191+
// src/panel.ts#L32-L36
191192

192193
private _logMessage(emitter: ButtonWidget, count: ICount): void {
193194
console.log('Hey, a Signal has been received from', emitter);

basics/signals/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
"watch:src": "tsc -w"
4343
},
4444
"dependencies": {
45-
"@jupyterlab/application": "~3.0.0-beta.4",
46-
"@jupyterlab/launcher": "~3.0.0-beta.4",
47-
"@jupyterlab/mainmenu": "~3.0.0-beta.4",
48-
"@jupyterlab/translation": "^3.0.0-beta.4",
45+
"@jupyterlab/application": "~3.0.0-beta.8",
46+
"@jupyterlab/launcher": "~3.0.0-beta.8",
47+
"@jupyterlab/mainmenu": "~3.0.0-beta.8",
48+
"@jupyterlab/translation": "^3.0.0-beta.8",
4949
"@lumino/algorithm": "^1.3.3",
5050
"@lumino/coreutils": "^1.5.3",
5151
"@lumino/datagrid": "^0.3.1",
@@ -72,4 +72,4 @@
7272
"extension": true,
7373
"outputDir": "jupyterlab_examples_signals/static"
7474
}
75-
}
75+
}

basics/signals/src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
JupyterFrontEnd,
3-
JupyterFrontEndPlugin
3+
JupyterFrontEndPlugin,
44
} from '@jupyterlab/application';
55

66
import { ICommandPalette } from '@jupyterlab/apputils';
@@ -30,7 +30,7 @@ const extension: JupyterFrontEndPlugin<void> = {
3030
autoStart: true,
3131
optional: [ILauncher],
3232
requires: [ICommandPalette, IMainMenu, ITranslator],
33-
activate: activate
33+
activate: activate,
3434
};
3535

3636
/**
@@ -45,8 +45,8 @@ function activate(
4545
app: JupyterFrontEnd,
4646
palette: ICommandPalette,
4747
mainMenu: IMainMenu,
48-
launcher: ILauncher | null,
49-
translator: ITranslator
48+
translator: ITranslator,
49+
launcher: ILauncher | null
5050
): void {
5151
const manager = app.serviceManager;
5252
const { commands, shell } = app;
@@ -57,7 +57,7 @@ function activate(
5757
if (launcher) {
5858
launcher.add({
5959
command: CommandIDs.create,
60-
category: category
60+
category: category,
6161
});
6262
}
6363

@@ -84,7 +84,7 @@ function activate(
8484
commands.addCommand(CommandIDs.create, {
8585
label: trans.__('Open the Signal Example Panel'),
8686
caption: trans.__('Open the Signal Example Panel'),
87-
execute: createPanel
87+
execute: createPanel,
8888
});
8989

9090
// Add items in command palette and menu

0 commit comments

Comments
 (0)