Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shouldn't postal.channel() implement the Singleton pattern? #173

Open
estaylorco opened this issue Apr 18, 2017 · 2 comments
Open

Shouldn't postal.channel() implement the Singleton pattern? #173

estaylorco opened this issue Apr 18, 2017 · 2 comments

Comments

@estaylorco
Copy link

I'm using postal.request-response and I noticed from the PostalJS code base that postal.channel() returns a new ChannelDefinition every time.

It seems to me that, if a ChannelDefinition exists for a particular channel, it should just return that instance. I mean, what is the meaning of the following:

const loginChannel1 = postal.channel('login');
const loginChannel2 = postal.channel('login');

Should we be able to have two distinct instances of a definition over the same channel?

This is interfering with postalRR because it would appear that both requester and responder need to have access to the same instance of ChannelDefinition, which defeats the purpose. Responders and requesters are almost invariably going to exist in different parts of the application.

Or am I missing something here?

Thank you.

@workforbala
Copy link

workforbala commented May 5, 2021

2021 still facing issue any update over here ?

@pinoniq
Copy link

pinoniq commented May 6, 2021

I don't see how this is an issue. Each channelDefiniton has access to the same Bus. And sbscribers are attached to that bus: https://github.com/postaljs/postal.js/blob/master/src/ChannelDefinition.js#L9

Can you provide a working example of where postal is not working as it should?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants