dimanche 21 janvier 2018

Ember JS: Service - Get data from Socket.io

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





Aucun commentaire:

Enregistrer un commentaire