Closed Zeichen32 closed 4 months ago
Sure, go ahead. Something like:
interface ConsumerProps {
/** If true, the consumer will not automatically start. You must call
* consumer.start() yourself.
* @default false */
lazy?: boolean
}
class Consumer {
/** When created with lazy=true, begin consuming. */
start(): void {}
}
Should be simple enough.
It would be really helpful if Consumer could be create without starting consuming messages directly. In my usecase i want to inject the Consumer via a dependencies injection Container into a Service and want to start consuming messages after some other dependencies are ready.
I think maybe adding a lazy boalean flag to the Option could control if the connect method is called in the constructor.
I can work on a PR if you are open for such a feature.