Skip to content

Commit

Permalink
Revert "Compatible ES6. fix #3"
Browse files Browse the repository at this point in the history
  • Loading branch information
domguinard committed Sep 18, 2016
1 parent 5192da1 commit 1f92b68
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
12 changes: 1 addition & 11 deletions plugins/corePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,10 @@ CorePlugin.prototype.showValue = function () {
console.info('Current value for %s is %s', this.model.name, util.inspect(this.model.data[this.model.data.length-1]));
};

/**
* Fake ObjectObserve if not available
*/
var objectObserver = Object.observe || function (resource, callback, extra) {
resource.push = function (data) {
Array.prototype.push.call(resource, data);
callback([{object: resource}]);
};
};

CorePlugin.prototype.observeActions = function () {
var self = this;
_.forEach(self.actions, function (actionId) { //#F
objectObserver(resources.links.actions.resources[actionId].data, function (changes) {
Object.observe(resources.links.actions.resources[actionId].data, function (changes) {
var action = changes[0].object[changes[0].object.length -1];
console.info('[plugin action detected] %s', actionId);
if (self.doAction) self.doAction(action);
Expand Down
15 changes: 2 additions & 13 deletions servers/websockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@ var WebSocketServer = require('ws').Server,
resources = require('./../resources/model'),
utils = require('./../utils/utils');

/**
* Fake Array.Observe if not available
*/
var ArrayObserver = Array.observe || function (resource, callback, extra) {
resource.push = function (data) {
Array.prototype.push.call(resource, data);
callback([{object: resource}]);
};
};

exports.listen = function (server) {
var wss = new WebSocketServer({server: server}); //#A
console.info('WebSocket server started...');
Expand All @@ -22,7 +12,7 @@ exports.listen = function (server) {
ws.send(JSON.stringify({'error': 'Invalid access token.'}));
} else {
try {
ArrayObserver(selectResource(reqUrl.pathname), function (changes) { //#C
Array.observe(selectResouce(reqUrl.pathname), function (changes) { //#C
ws.send(JSON.stringify(changes[0].object[changes[0].object.length - 1]), function () {
});
}, ['add'])
Expand All @@ -33,7 +23,7 @@ exports.listen = function (server) {
});
};

function selectResource(url) { //#E
function selectResouce(url) { //#E
var parts = url.split('/');
parts.shift();
var result;
Expand All @@ -42,7 +32,6 @@ function selectResource(url) { //#E
} else {
result = resources.links.properties.resources[parts[1]].data;
}
console.log(result);
return result;
}

Expand Down

0 comments on commit 1f92b68

Please sign in to comment.