mardi 26 avril 2016

EmberJS all websocket communication

So I'm fairly confused on how to go about this. I'm developing an somewhat complex ember app thats similar to a forum and I'm simply am not using ajax at all, all communications are going through websockets powered by socket.io.

The easy part was getting socket.io up and running, the hard part is how to go about with communication. I've seen loads of stuff all over the web with all different kinds of answers but while they answer some questions theres a lot they don't answer.

In short, I can somewhat grasp loading general content data, I say somewhat because I'm not using a relational database but instead a graph database so find methods like findAll are generally useless since on the backend I'm going about things completely different but I can keep it somewhat manageable and just load in the response in a way that makes ember and ember data happy.

But what I'm loading is more than content data like posts and stuff. I'm also loading in error messages for different actions like invalid login or 404 messages for posts, jwt tokens for successful logins, possibly vector images or special content. This is where things get complicated because it seems ember is designed to mainly store and load content data, stuff with an id that can be fetched individually, in a range, filtered out, etc... but I'm really torn on how to bring in the other stuff as ember seems to only load stuff into handlebars from a model.

So, from what I can gather, the best solution is to create a model for each and every page in my site to hold page data like error messages, special content, or other non-content stuff. Request the data, and then load the data to that page model. It seems like a really whacky way of doing things and I'm almost tempted to say that ember just isnt the solution for me but I figured I'd ask the community and see what they say.




Aucun commentaire:

Enregistrer un commentaire