0

My interface is a curve that changes everytime the server sends to ember a new value of the curve's parameter, and that's happen every second probably.it's very dynamic So i'm trying to receive the data using a websocket from my golang server. to load the data in the store , i'm asked to use the fixture adapter. I opened the socket using:

App.ApplicationRoute = Ember.Route.extend({
activate: function() {
    var socket = window.io.connect('http://localhost:8080');
    var self = this;

 }

});

but i'm asking for the next steps, how to receive the data and load it in the store ?

Thank you!

Farah
  • 75
  • 2
  • 8
  • this is my model, my store! //Post Model App.Post = DS.Model.extend({ name: DS.attr('string'), number: DS.attr('string') }); App.Store = DS.Store.extend({ revision: 12, //API revision number adapter: DS.FixtureAdapter({ }) }); App.PostRoute = Ember.Route.extend({ model: function() { return this.store.find("post"); } }); – Farah May 04 '14 at 08:57

1 Answers1

0

You can just push new objects to the store. Take a look at this example: http://emberjs.jsbin.com/dariy/2/edit

In this example the setInterval() method is used, you can easily change this to something like

...
var socket = window.io.connect('http://localhost:8080');
var self = this;
socket.on('test', function (data) {            
    self.store.push('post',   {
        name:  data.name,
        number: data.nr
    });
}); 
... 

However, I don't think the fixture adapter is really designed to use in production environments, but if it meets your requirements, why not.

Bavo Van Geit
  • 855
  • 6
  • 15