Skip to content

Commit

Permalink
♻️ Rename getEvent to getLastEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinbeggi committed Apr 1, 2022
1 parent c3feb37 commit fcab1b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ EventBridge.build(busName); // create a EventBridge instance to allow events to

```ts
eventBridge.publishEvent(source, detailType, detail); // publish an event to the bus
eventBridge.getEvent(); // get the last event that has been sent to the bus
eventBridge.getLastEvent(); // get the last event that has been sent to the bus
eventBridge.getAllEvents(); // get all the events that have been sent to the bus
eventBridge.clear(); // clear old messages
eventBridge.destroy(); // remove infastructure used to track events
Expand Down Expand Up @@ -202,7 +202,7 @@ describe("Integration Testing Event Bridge", () => {
};
await lambda.invoke(params).promise();

const eventBridgeEvents = await eventBridge.getEvent()
const eventBridgeEvents = await eventBridge.getLastEvent()
expect(eventBridgeEvents).toHaveEvent();
expect(eventBridgeEvents).toHaveEventWithSource("order.created");
});
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/eventBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ export default class EventBridge {
})
.promise();

await this.getEvent(); // need to clear this manual published event from the SQS observer queue.
await this.getLastEvent(); // need to clear this manual published event from the SQS observer queue.

return result;
}

async getEvent(): Promise<SQS.ReceiveMessageResult | undefined> {
async getLastEvent(): Promise<SQS.ReceiveMessageResult | undefined> {
if (this.QueueUrl === undefined) {
throw new Error("QueueUrl is undefined");
}
Expand Down Expand Up @@ -181,7 +181,7 @@ export default class EventBridge {

while (!allEventsFound) {
try {
const lastEventBridgeEvents = await this.getEvent();
const lastEventBridgeEvent = await this.getLastEvent();

if (!lastEventBridgeEvents || !lastEventBridgeEvents.Messages) {
return allEventBridgeEvents;
Expand Down

0 comments on commit fcab1b5

Please sign in to comment.