diff --git a/types/cote/cote-tests.ts b/types/cote/cote-tests.ts index 908c145c61..8fd52a73a4 100644 --- a/types/cote/cote-tests.ts +++ b/types/cote/cote-tests.ts @@ -118,16 +118,16 @@ class Readme { }); setInterval(() => { - const action = { + const event = { type: 'randomUpdate', payload: { val: Math.floor(Math.random() * 1000) } }; - console.log('emitting', action); + console.log('emitting', event); - randomPublisher.publish('randomUpdate', action); + randomPublisher.publish('randomUpdate', event); }, 3000); } @@ -245,8 +245,8 @@ class Readme { * @see https://github.com/makepost/DefinitelyTyped/projects/1 */ class InitialObservations { - action() { - const action: cote.Action = { type: 'someAction' }; + event() { + const event: cote.Event = { type: 'someEvent' }; } eventEmitter() { diff --git a/types/cote/index.d.ts b/types/cote/index.d.ts index f0841c77be..ee6d8c4324 100644 --- a/types/cote/index.d.ts +++ b/types/cote/index.d.ts @@ -44,18 +44,18 @@ export class Requester extends Component { * Queues a request until a Responder is available, and once so, delivers * the request. Requests are dispatched to Responders in a round-robin way. * - * @param action Request. + * @param event Request. */ - send(action: T): Promise; + send(event: T): Promise; /** * Queues a request until a Responder is available, and once so, delivers * the request. Requests are dispatched to Responders in a round-robin way. * - * @param action Request. + * @param event Request. * @param callback Function to execute after getting a result. */ - send(action: T, callback: (result: any) => void): void; + send(event: T, callback: (result: any) => void): void; } /** @@ -82,13 +82,13 @@ export class Responder extends Component { ); /** - * Listens to internal `cote:added` and `cote:removed` actions. + * Listens to internal `cote:added` and `cote:removed` events. * * @param listener Callback. */ on( type: 'cote:added' | 'cote:removed', - listener: (action: Status) => void + listener: (event: Status) => void ): this; /** @@ -97,11 +97,11 @@ export class Responder extends Component { * @param type Type. May be wildcarded or namespaced like in EventEmitter2. * @param listener Callback. Should return a result. */ - on( + on( type: string | string[], listener: ( - ((action: T, callback: (result: any) => void) => void) | - ((action: T) => Promise) + ((event: T, callback: (result: any) => void) => void) | + ((event: T) => Promise) ) ): this; } @@ -134,11 +134,11 @@ export class Publisher extends Component { * there are no Subscribers listening, the event is lost. * * @param type EventEmitter-compatible type. - * @param action Request. + * @param event Request. */ - publish( + publish( type: string, - action: T + event: T ): void; } @@ -171,9 +171,9 @@ export class Subscriber extends Component { * @param type Type. May be wildcarded or namespaced like in EventEmitter2. * @param listener Callback. Returns nothing. */ - on( + on( type: string | string[], - listener: (action: T) => void + listener: (event: T) => void ): this; } @@ -278,21 +278,21 @@ export class TimeBalancedRequester extends Requester { export class PendingBalancedRequester extends Requester { } /** - * Action is nothing but object with `type`. + * Event is nothing but object with `type`. */ -export interface Action { +export interface Event { type: string; } /** - * Internal `cote:added` and `cote:removed` actions. + * Internal `cote:added` and `cote:removed` events. */ -export interface Status extends Action { +export interface Status extends Event { advertisement: StatusAdvertisement; } /** - * Advertisement in internal `cote:added` and `cote:removed` actions. + * Advertisement in internal `cote:added` and `cote:removed` events. */ export interface StatusAdvertisement extends RequesterAdvertisement,