WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

(How To?) Identify the source/sender of the broadcast messageΒ #3

@borntorun

Description

@borntorun

Hi,

I'm using localDataStorage (excellent work β—πŸ‘πŸ‘, by the way) in a web application to manage some data that needs to be synchronized between tabs.

Using the Broadcast Channel API, all tabs receive the broadcast message to react to changes in the storage. Including the one sending the message..., and this the "issue".

To ignore messages sent from your own tab (in my web application's logic, this would result in unnecessary duplication of work), you'd need a way to identify the source/sender of each message.

I couldn't identify this with the current library logic. (Maybe I missed something and wasn't looking in the right place...)

This would be feasible if we could define a unique "sender" for each instance/tab, like this:


localData = localDataStorage(..., senderId);

// or

// localDataStorage internally to create a unique senderId to be retrieved like (I prefer this one):

senderId = localData.senderId;


This "senderId" would be part of the "event.data" that's passed in the broadcast message.

What do you think about this? Would you be willing to include this new functionality?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions