getoutreach / epf

A framework for keeping your Ember.js apps in sync.
http://epf.io
MIT License
369 stars 33 forks source link

Wisdom for creating Web Socket Adapter? #117

Closed cjam closed 10 years ago

cjam commented 10 years ago

Hello,

I'm just getting started with emberjs and epf and I was thinking that I'd like to make a web socket adapter for EPF (as one of the goals of my project is real time / web socket based). I was going to base my implementation on the rest adapter but just wanted to see if anyone had any words of wisdom of components in there that might not apply to the web socket scenario or any gotchas to watch out for.

Thanks.

Colter

ghempton commented 10 years ago

Are you planning on using the adapter for writing or just receiving updates?

cjam commented 10 years ago

I wanted to try and handle both sending and receiving. I took a look at the rest adapter and the base adapter class. There is a lot of code in the rest adapter related to handling relationships and embedded records. Is that code specific to rest? It seems like any adapter would have to maintain the relationships.

Colter

On Feb 8, 2014, at 10:17 AM, "Gordon L. Hempton" notifications@github.com wrote:

Are you planning on using the adapter for writing or just receiving updated?

Reply to this email directly or view it on GitHubhttps://github.com/GroupTalent/epf/issues/117#issuecomment-34547927 .

ghempton commented 10 years ago

Sorry for the delayed response. I just finished a pretty major refactor to the way adapters work. In a nutshell, a socket adapter should be very straightforward. In adapter.js there are several methods that need to be implemented: load, query, refresh, and flush. These methods should hit the server and call mergeData with the resulting data.

The trickiest part will be the flush method which needs to take into account dependencies between models. I am thinking about adding a "flush mode" to the session which would have a setting that causes it to automatically flush after any operation.

cjam commented 10 years ago

Hello Gordon,

So I've spent a little bit of time trying to get a socket adapter to work. I'm having some difficulties in just lack of knowledge with the way that EPF handles data it receives and how it wires it back up to the right models. I suspect that it uses the client_id and the rev properties (from serializing) to determine which direction it should be merging models etc. But i'm just wondering more the flow of how this all fits together.

I'm using socket stream and I've written some simple actions that are exposed to the client for saving, finding and removing models. These actions take the model type and the model itself. All of my models obviously have their mongo _id, do I need to also add a client_id and rev property to these models when storing them?

Thanks for any help you can give me,

Colter

On Tue, Feb 25, 2014 at 8:53 PM, Gordon L. Hempton <notifications@github.com

wrote:

Sorry for the delayed response. I just finished a pretty major refactor to the way adapters work. In a nutshell, a socket adapter should be very straightforward. In adapter.js there are several methods that need to be implemented: load, query, refresh, and flush. These methods should hit the server and call mergeData with the resulting data.

The trickiest part will be the flush method which needs to take into account dependencies between models. I am thinking about adding a "flush mode" to the session which would have a setting that causes it to automatically flush after any operation.

Reply to this email directly or view it on GitHubhttps://github.com/GroupTalent/epf/issues/117#issuecomment-36085720 .