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

Record listens should return the amount of subscribers interested in the record #74

Closed
Lalem001 opened this issue Feb 18, 2016 · 10 comments
Assignees
Milestone

Comments

@Lalem001
Copy link
Contributor

Lalem001 commented Feb 18, 2016

Given the ds-demo-provider, generator will never stop generating after first subscription.

Stepping through the logic:

  • Server and provider are started
  • Client connects and subscribes to FX/* record
  • onSubscription is called
    • isSubscribed is true
    • fx-data-provider subscribes to FX/* record
    • There are now two subscribers!
  • Client disconnects.
  • One subscriber (fx-data-provider) remains, onSubscription is not called.

I was hoping to have on-demand providers in my current project.
Any suggestions on how to resolve this issue?

@yasserf
Copy link
Contributor

yasserf commented Feb 18, 2016

The ds-demo dependencies are out of date. Will look at it in the next hour and keep you updated.

@yasserf
Copy link
Contributor

yasserf commented Feb 18, 2016

Hey! Right so you were totally correct. This is actually a design issue I'll discuss with the rest of the core team tomorrow.

We might need to have a different kind of record which is a silent requester so that is doesn't let deepstream know it has the the record. I think that would probably be quite a bit of work tho so will sleep over a solution.

This works great for events so far since they are stateless, but I can see this happening often with records.

Thanks for raising!

@yasserf yasserf changed the title "Data Provider" issue Record listens should return the amount of subscribers interested in the record Feb 19, 2016
@yasserf
Copy link
Contributor

yasserf commented Feb 19, 2016

So we have decided on the following as an API change

record.listen( '/bob/', function( recordName, numberOfSubscribers ) {
} );

This way if numberOfSubscribers === 1 and your already providing it you would know to stop.
This is also the least invasive in terms of APIs.

Thoughts?

@Lalem001
Copy link
Contributor Author

That is a reasonable solution.

Will the function be called per subscription? What happens when transitioning from 1 to 2 subscribers? 1 to 0?

@yasserf
Copy link
Contributor

yasserf commented Feb 19, 2016

Should be called everytime a match occur. Will try implementing today and let you know!

@Lalem001
Copy link
Contributor Author

Lalem001 commented Mar 3, 2016

Any updates on this issue?

@yasserf
Copy link
Contributor

yasserf commented Mar 3, 2016

Not yet, it will be in our next release but we are currently focusing on getting a couple more tutorials out on how to use deepstream with different front-end libraries.

@Lalem001
Copy link
Contributor Author

Lalem001 commented Mar 3, 2016

Not to derail the original topic, but I am very interested to see these tutorials. Have any links?

@yasserf
Copy link
Contributor

yasserf commented Mar 4, 2016

They are still a work in progress. Currently polymer elements and a react mixin. Should be issues on website repo you can follow!

@yasserf
Copy link
Contributor

yasserf commented Apr 11, 2016

We need to think of a better way to indicate if a record is subscribed to or not than providing numbers.

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

2 participants