Skip to content

[Mercure] Explain how to differentiate between multiple topics in JavaScript #20574

Closed
@ThomasLandauer

Description

@ThomasLandauer

At https://symfony.com/doc/current/mercure.html#subscribing it is described how to subscribe to multiple topics:

const eventSource = new EventSource("{{ mercure(['topic1', 'topic2']) }}");

But when looking at the received data, how is it possible to know which is coming from topic1 and which from topic2?

At https://stackoverflow.com/a/71905295/1668200 it is suggested to use Update()s fifth argument $type, and in JavaScript add multiple event listeners to EventSource . Is this really the recommended way? If yes, then the recommendation would be to use the (more or less) same string for $topic and $type?

Metadata

Metadata

Assignees

No one assigned

    Labels

    MercurehasPRA Pull Request has already been submitted for this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions