Is this an app appropriate way to get data into a Service?
This is what I'd like to have happen.
import Ember from 'ember';
export default Ember.Service.extend({
model: (function() {
var data = [];
var socket = io.connect('http://localhost:8080');
socket.on('posts', function (data) {
data = data.posts;
console.log(data);
});
return data;
})()
});
Is there a proper way to go about this?
Is this an app appropriate way to get data into a Service.
File Location app/services/posts.js
I assume you want something like this:
However you should know that
datawill first bynulland then later update when the data from the socket arrives. The other way is to return aPromise, but with this solution you can use the socket to update your data later.