|
|
|
@ -1,3 +1,12 @@ |
|
|
|
import { |
|
|
|
EventCallbackAdd, |
|
|
|
EventCallbackAll, |
|
|
|
EventCallbackRemove, |
|
|
|
EventCallbackRemoveBefore, |
|
|
|
SetOptions, |
|
|
|
} from '../common'; |
|
|
|
import Device, { DeviceProperties } from './model/Device'; |
|
|
|
|
|
|
|
/**{START_EVENTS}*/ |
|
|
|
export enum DeviceEvents { |
|
|
|
/** |
|
|
|
@ -17,17 +26,17 @@ export enum DeviceEvents { |
|
|
|
removeBefore = 'device:remove:before', |
|
|
|
|
|
|
|
/** |
|
|
|
* @event `device:select` A new device is selected. The `Device` is passed as an argument. |
|
|
|
* @event `device:select` A new device is selected. Current and previous `Device` are passed as arguments. |
|
|
|
* @example |
|
|
|
* editor.on('device:select', (device) => { ... }); |
|
|
|
* editor.on('device:select', (newDevice, prevDevice) => { ... }); |
|
|
|
*/ |
|
|
|
select = 'device:select', |
|
|
|
selectBefore = 'device:select:before', |
|
|
|
|
|
|
|
/** |
|
|
|
* @event `device:update` Device updated. The `Device` and the object containing changes are passed as arguments. |
|
|
|
* @event `device:update` Device updated. The `Device`, changed properties, and update options are passed as arguments. |
|
|
|
* @example |
|
|
|
* editor.on('device:update', (device) => { ... }); |
|
|
|
* editor.on('device:update', (device, changes, options) => { ... }); |
|
|
|
*/ |
|
|
|
update = 'device:update', |
|
|
|
|
|
|
|
@ -40,5 +49,16 @@ export enum DeviceEvents { |
|
|
|
} |
|
|
|
/**{END_EVENTS}*/ |
|
|
|
|
|
|
|
export type DeviceEvent = `${DeviceEvents}`; |
|
|
|
|
|
|
|
export interface DevicesEventCallback { |
|
|
|
[DeviceEvents.add]: EventCallbackAdd<Device>; |
|
|
|
[DeviceEvents.remove]: EventCallbackRemove<Device>; |
|
|
|
[DeviceEvents.removeBefore]: EventCallbackRemoveBefore<Device>; |
|
|
|
[DeviceEvents.select]: [Device | null | undefined, Device | null | undefined]; |
|
|
|
[DeviceEvents.update]: [Device, Partial<DeviceProperties>, SetOptions]; |
|
|
|
[DeviceEvents.all]: EventCallbackAll<DeviceEvent, Device>; |
|
|
|
} |
|
|
|
|
|
|
|
// This is necessary to prevent the TS documentation generator from breaking.
|
|
|
|
export default DeviceEvents; |
|
|
|
|