Skip to content

Improve Processor with a lot of similar events with common interface #829

@tuxes3

Description

@tuxes3

Hello 👋

I am working on a case where a Processor is processing a lot events which are all similar, but a bit different. In fact all the events share a common Interface.

Currently my Code looks roughly like this:

#[Processor('some.thing')]
final readonly class SomeProcessor
{
    #[Subscribe(ThingHasHappenend::class)]
    #[Subscribe(SimilairThingHasHappened::class)]
    .... 45 more events
    public function onNewAnswerableBlockAdded(Message $message): void
   {
       /** @var SomeCommenInterface $event */
        $event = $message->event();
        ... do something with this event
    }
}

Would it be possible to subscribe to a Interface and catch all events implementing it?

Thanks for the bundle!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions