import { RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/redis-pub-sub-event-bus-adapter";
import { Serde } from "@daiso-tech/core/serde";
import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/super-json-serde-adapter"
import Redis from "ioredis";
const client = new Redis("YOUR_REDIS_CONNECTION_STRING");
const serde = new Serde(new SuperJsonSerdeAdapter());
const eventBusAdapter = new RedisPubSubEventBusAdapter({
client,
serde,
});
The addListener method is used for adding EventListenerFn for certain eventName.
The dispatch method is used for dispatching one or multiple events.
The removeListener method is used for removing EventListenerFn for certain eventName.
To utilize the
RedisPubSubEventBusAdapter, you must install the"ioredis"package and supply aISerde, with aSuperJsonSerdeAdapter.IMPORT_PATH:
"@daiso-tech/core/event-bus/redis-pub-sub-event-bus-adapter"