Skip to content

Commit

Permalink
Fix event.subscribe types: arc.events.subscribe does not return unkno…
Browse files Browse the repository at this point in the history
…wn, but a function returning a promise or not, depending on whether an async or callback function was provided to subscribe

dont care about args to callbacks
  • Loading branch information
filmaj committed Aug 17, 2024
1 parent 865268c commit 08ccc44
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions types/events.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,14 @@ interface Params<Payload> {
payload: Payload;
}

// Consumers of this library should not care exactly what this is. Just that
// it's a lambda function which should be exported as a handler.
type LambdaFunction = unknown;

interface EventsOrQueues<PublishResult> {
publish<Payload = any>(params: Params<Payload>): Promise<PublishResult>;
publish<Payload = any>(
params: Params<Payload>,
callback: Callback<PublishResult>,
): void;
subscribe<Event = any>(
handler:
| ((event: Event) => Promise<void>)
| ((event: Event, callback: Callback<void>) => void),
): LambdaFunction;
subscribe<Event = any>(handler: (e: Event) => Promise<void>): (e: Event) => Promise<void>;
subscribe<Event = any>(handler: (e: Event, callback: Function) => void): (e: Event, context: any, callback: Function) => void;
}

export type ArcEvents = EventsOrQueues<SnsPublishResponse>;
Expand Down

0 comments on commit 08ccc44

Please sign in to comment.