Skip to content

Commit b4aa1e0

Browse files
Take review comments about signals into account.
1 parent 5622f86 commit b4aa1e0

3 files changed

Lines changed: 53 additions & 53 deletions

File tree

src/bluetooth-extension/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const BluetoothSidebarPlugin: JupyterFrontEndPlugin<void> = {
9494
]
9595
}).then(async result => {
9696
if (result.button.accept) {
97-
bluetoothManager.deviceTypeRegistry.itemsList.forEach(
97+
bluetoothManager.deviceTypeRegistry.deviceTypes.forEach(
9898
async item => {
9999
if (item.deviceType === result.value) {
100100
await bluetoothManager.connect(item);
@@ -160,7 +160,7 @@ export class DropDownRegistry
160160
this._selectList = document.createElement('select');
161161
this.node.appendChild(this._selectList);
162162
this.registry = registry;
163-
registry.itemsList.forEach(item => {
163+
registry.deviceTypes.forEach(item => {
164164
const option = document.createElement('option');
165165
option.value = item.deviceType;
166166
option.text = item.deviceType;

src/bluetooth/BluetoothManager.ts

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -241,65 +241,65 @@ export namespace BluetoothManager {
241241
}
242242

243243
export class DeviceTypeRegistry implements IDeviceTypeRegistry {
244-
private _deviceTypeRegistry: Array<IDeviceTypeRegistryItem>;
245-
private _registeredByAPlugin: Signal<
246-
this,
247-
BluetoothManager.DeviceTypeRegistry
248-
>;
249-
250-
public registryItem: IDeviceTypeRegistryItem;
251244
constructor() {
252-
this._deviceTypeRegistry = [];
253-
this._registeredByAPlugin = new Signal<
245+
this._deviceTypes = [];
246+
this._added = new Signal<
254247
this,
255-
BluetoothManager.DeviceTypeRegistry
248+
IDeviceTypeRegistryItem
256249
>(this);
257250
}
258251

259252
add(registryItem: IDeviceTypeRegistryItem) {
260-
this._deviceTypeRegistry.push(registryItem);
253+
this._deviceTypes.push(registryItem);
254+
this._added.emit(registryItem)
261255
}
262-
get itemsList(): Array<IDeviceTypeRegistryItem> {
263-
return this._deviceTypeRegistry;
256+
257+
get deviceTypes(): IDeviceTypeRegistryItem[] {
258+
return this._deviceTypes;
264259
}
265-
get registeredByAPlugin(): Signal<
260+
261+
get added(): Signal<
266262
this,
267-
BluetoothManager.DeviceTypeRegistry
263+
IDeviceTypeRegistryItem
268264
> {
269-
return this._registeredByAPlugin;
265+
return this._added;
270266
}
267+
268+
private _deviceTypes: Array<IDeviceTypeRegistryItem>;
269+
private _added: Signal<
270+
this,
271+
IDeviceTypeRegistryItem
272+
>;
273+
274+
public registryItem: IDeviceTypeRegistryItem;
271275
}
272276
}
273277

274-
/**
275-
* Interface for the bluetooth manager.
276-
*/
277-
export interface IBluetoothManager {
278-
removeAllDevices(Devices: Array<BluetoothManager.Device>): void;
279-
connect(registryItem: IDeviceTypeRegistryItem): any;
280-
disconnect(device: BluetoothManager.Device): void;
281-
deviceListChanged: Signal<BluetoothManager, Array<BluetoothManager.Device>>;
282-
get deviceList(): Array<BluetoothManager.Device>;
283-
get deviceTypeRegistry(): BluetoothManager.DeviceTypeRegistry;
284-
}
278+
/**
279+
* Interface for the bluetooth manager.
280+
*/
281+
export interface IBluetoothManager {
282+
removeAllDevices(Devices: Array<BluetoothManager.Device>): void;
283+
connect(registryItem: IDeviceTypeRegistryItem): any;
284+
disconnect(device: BluetoothManager.Device): void;
285+
deviceListChanged: Signal<BluetoothManager, Array<BluetoothManager.Device>>;
286+
get deviceList(): Array<BluetoothManager.Device>;
287+
get deviceTypeRegistry(): BluetoothManager.DeviceTypeRegistry;
288+
}
285289

286-
export interface IDeviceTypeRegistryItem {
287-
deviceType: string;
288-
factory: (
289-
native: BluetoothDevice
290-
) => Promise<BluetoothManager.Device | undefined>;
291-
options: IDeviceOptions;
292-
}
290+
export interface IDeviceTypeRegistryItem {
291+
deviceType: string;
292+
factory: (
293+
native: BluetoothDevice
294+
) => Promise<BluetoothManager.Device | undefined>;
295+
options: IDeviceOptions;
296+
}
293297

294-
export interface IDeviceTypeRegistry {
295-
add: (registryItem: IDeviceTypeRegistryItem) => void;
296-
get deviceTypes(): IDeviceTypeRegistryItem[];
297-
get registeredByAPlugin(): Signal<
298-
IDeviceTypeRegistry,
299-
BluetoothManager.DeviceTypeRegistry
300-
>;
301-
}
298+
export interface IDeviceTypeRegistry {
299+
add: (registryItem: IDeviceTypeRegistryItem) => void;
300+
get deviceTypes(): IDeviceTypeRegistryItem[];
301+
}
302302

303-
export const IBluetoothManager = new Token<IBluetoothManager>(
304-
'@jupyterlab/bluetooth:manager'
305-
);
303+
export const IBluetoothManager = new Token<IBluetoothManager>(
304+
'@jupyterlab/bluetooth:manager'
305+
)

src/movehub-extension/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ const MoveHubRegisterPlugin: JupyterFrontEndPlugin<void> = {
5757
): void => {
5858
console.log('JupyterLab move-hub-register plugin is activated!');
5959
bluetoothManager.deviceTypeRegistry.add(movehubRegistryItem);
60-
bluetoothManager.deviceTypeRegistry.registeredByAPlugin.emit(
61-
bluetoothManager.deviceTypeRegistry
62-
);
63-
console.warn(
64-
`New item from category ${movehubRegistryItem} is added to the registry.`
65-
);
60+
bluetoothManager.deviceTypeRegistry.added.connect(
61+
async (sender, movehubRegistryItem) => {
62+
console.warn(
63+
`New item from category ${movehubRegistryItem.deviceType} is added to the deviceType registry.`
64+
);
65+
})
6666
}
6767
};
6868

0 commit comments

Comments
 (0)