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!

4

1 回答 1

0

您可以将新对象推送到商店。看看这个例子:http ://emberjs.jsbin.com/dariy/2/edit

在此示例中使用了 setInterval() 方法,您可以轻松地将其更改为类似

...
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
    });
}); 
... 

但是,我不认为夹具适配器真的设计用于生产环境,但如果它满足您的要求,为什么不呢。

于 2014-05-04T13:15:30.607 回答