@@ -21,7 +21,7 @@ JupyterLab's Lumino engine uses the `ISignal` interface and the
21
21
22
22
The basic concept is as follows:
23
23
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
25
25
some visual elements such as a button, defines a ` _stateChanged ` signal:
26
26
27
27
``` ts
@@ -44,7 +44,7 @@ Another widget, in this case the panel (`panel.ts`) that boxes several different
44
44
subscribes to the ` stateChanged ` signal and links some function to it:
45
45
46
46
``` ts
47
- // src/panel.ts#L22-L22
47
+ // src/panel.ts#L29-L29
48
48
49
49
this ._widget .stateChanged .connect (this ._logMessage , this );
50
50
```
@@ -141,13 +141,14 @@ The `panel.ts` class defines an extension panel that displays the
141
141
This is done in the constructor.
142
142
143
143
``` ts
144
- // src/panel.ts#L13-L23
144
+ // src/panel.ts#L19-L30
145
145
146
- constructor () {
147
146
super ();
147
+ this ._translator = translator || nullTranslator ;
148
+ this ._trans = this ._translator .load (' jupyterlab' );
148
149
this .addClass (PANEL_CLASS );
149
150
this .id = ' SignalExamplePanel' ;
150
- this .title .label = ' Signal Example View' ;
151
+ this .title .label = this . _trans . __ ( ' Signal Example View' ) ;
151
152
this .title .closable = true ;
152
153
153
154
this ._widget = new ButtonWidget ();
@@ -160,7 +161,7 @@ Subscription to a signal is done using the `connect` method of the
160
161
` stateChanged ` attribute.
161
162
162
163
``` ts
163
- // src/panel.ts#L22-L22
164
+ // src/panel.ts#L29-L29
164
165
165
166
this ._widget .stateChanged .connect (this ._logMessage , this );
166
167
```
@@ -178,7 +179,7 @@ The `_logMessage` function receives as parameters the emitter (of type `ButtonWi
178
179
and the count (of type ` ICount ` ) sent by the signal emitter.
179
180
180
181
``` ts
181
- // src/panel.ts#L25-L25
182
+ // src/panel.ts#L32-L32
182
183
183
184
private _logMessage (emitter : ButtonWidget , count : ICount ): void {
184
185
` ` `
@@ -187,7 +188,7 @@ In our case, that function writes `Button has been clicked ... times.` text
187
188
to the browser console and in an alert when the big red button is clicked.
188
189
189
190
` ` ` ts
190
- // src/panel.ts#L25-L29
191
+ // src/panel.ts#L32-L36
191
192
192
193
private _logMessage (emitter : ButtonWidget , count : ICount ): void {
193
194
console .log (' Hey, a Signal has been received from' , emitter );
0 commit comments