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

Is it possible to use ember infinity with web sockets ? #367

Open
anpenava opened this issue Mar 11, 2019 · 4 comments
Open

Is it possible to use ember infinity with web sockets ? #367

anpenava opened this issue Mar 11, 2019 · 4 comments

Comments

@anpenava
Copy link

I am just wondering if I always peekAll my data from store can I still config this addon to give me specific number of data at the time.

@snewcomer
Copy link
Collaborator

snewcomer commented Mar 11, 2019

@anpenava Do you have any code that you could share to help us figure out if it is possible? I'm thinking not since we depend on ember-data for fetching data, but I haven't dealt with websockets in an ember app before.

@anpenava
Copy link
Author

anpenava commented Mar 12, 2019

@snewcomer This approach is also using ember data, but only peekAll every new event that comes in,because of sockets no need for requests, but that is my concern can this work with ember infinity.

import Route from '@ember/routing/route';

export default Route.extend({
  model() {
      return { 
	points: this.get('store').peekAll('point'),
	entries: this.get('store').peekAll('entry'),
      };
   },

   setupController(controller, model) {
     this._super(controller, model);
     controller.someMethod();
   }
});

from controller

   // someMethod(){...}
   // some magic to subscribe and setup websockets
   ...
   handlePointsUpdate(pointsRecordsPayload) {
	console.log('Got data: ' + JSON.stringify(pointsRecordsPayload));
	this.get("store").pushPayload('point', pointsRecordsPayload);
   },
   // handle entries...

@anpenava
Copy link
Author

So basically I would need connect each my new subscribe to page 2,3,4,5... to infinity scroll logic

@snewcomer
Copy link
Collaborator

@anpenava Seems like it would work using one of these methods -> https://github.com/ember-infinity/ember-infinity#service-methods

What do you think?

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