Creating EventBus adapters
Implementing your custom IEventBusAdapter
In order to create an adapter you need to implement the IEventBusAdapter contract.
Testing your custom IEventBusAdapter
We provide a complete test suite to verify your event-bus adapter implementation. Simply use the eventBusAdapterTestSuite function:
The suite provides preconfigured Vitest test cases with common edge case coverage and standardized event-bus adapter contract conformance testing.
Usage example:
import { describe, test, beforeEach, expect } from "vitest";
import { eventBusAdapterTestSuite } from "eridu-tech/event-bus/test-utilities";
import { MemoryEventBusAdapter } from "eridu-tech/event-bus/memory-event-bus-adapter";
describe("class: MyEventBusAdapter", () => {
eventBusAdapterTestSuite({
createAdapter: () => new MemoryEventBusAdapter(),
test,
beforeEach,
expect,
describe,
});
});
Implementing your custom IEventBus class
In some cases, you may need to implement a custom EventBus class to optimize performance for your specific technology stack. You can then directly implement the IEventBus contract.
Testing your custom IEventBus class
We provide a complete test suite to verify your custom event-bus class implementation. Simply use the eventBusTestSuite function:
The suite provides preconfigured Vitest test cases with common edge case coverage and standardized event-bus contract conformance testing.
Usage example:
import { describe, test, beforeEach, expect } from "vitest";
import { eventBusTestSuite } from "eridu-tech/event-bus/test-utilities";
import { EventBus } from "eridu-tech/event-bus";
import { MemoryEventBusAdapter } from "eridu-tech/event-bus/memory-event-bus-adapter";
describe("class: EventBus", () => {
eventBusTestSuite({
createEventBus: () =>
new EventBus({
adapter: new MemoryEventBusAdapter(),
}),
test,
beforeEach,
expect,
describe,
});
});
Further information
For further information refer to eridu-tech/event-bus API docs.