Skip to content

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

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy