Multiple Websocket Angularjs services Send rxjs array from one to other

In controller:

$scope.logs = [
        name: '',
        data: []

This data is put there by nodejs websocket server when file in directory changes using callback function. I want to rxjs this to another websocket connection

socket.on(, function(data){
    var observable = Rx.Observable.interval(1000).take( =>[t]);
    observable.subscribe(t => {

But the array data changes when the callback function is run, since it is a static log I can store an index of which value last was sent to the second service. Any ideas of how to best broadcast an array filled asynchronously by 1 websocket connection to another?

Second Service in Angularjs

.service('Device', function ($rootScope, $websocket) {
var ws = $websocket('ws://localhost:9000/greeter/');

ws.onOpen(function() {
    ws.send('Hello World');

ws.onMessage(function(message) {
    //console.log('message: ', message);
var res;
    try {
      res = JSON.parse(;
    } catch(e) {
      res = {'username': 'anonymous', 'message':};

this.send = function (message) {//tie to Send button
        if (angular.isString(message)) {

Source: AngularJS

Related Post