Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD: undefined value judgment #277

Closed
wants to merge 1 commit into from
Closed

Conversation

ariafloat
Copy link

Solution of Issues #276.

In the following application,

module.exports = function(server) {
  var photocellQuery = server.where({ type: 'photocell' });
  var ledQuery = server.where({ type: 'led' });
  server.observe([photocellQuery, ledQuery], function(photocell, led){
    photocell.streams.intensity.on('data', function(m) {
      if(m.data < 0.5) {
        if (led.available('turn-on')) {
          led.call('turn-on');
        }
      } else {
        if (led.available('turn-off')) {
          led.call('turn-off');
       }
     }
   });
});}

After [led.call('turn-on');] was called, the following of [virtual_device.js] is called.

this._socket.on(logTopic, function(data) {
  self._update(data);
  self._eventEmitter.emit(data.transition);
});

But there are no "actions" properties in "data".

Therefore [this._actions = entity.actions;] will be undefined by the following of [virtual_device.js],

VirtualDevice.prototype._update = function(entity) {
  var self = this;
  Object.keys(entity.properties).forEach(function(prop) {
    self[prop] = entity.properties[prop];
  });
  this._actions = entity.actions;

  if(entity.links) {
    this._links = entity.links;
  }
};

and an error is output by [this._actions.some(function(action) {... ].

@mdobson
Copy link
Contributor

mdobson commented Jan 12, 2016

@ariafloat Thanks for the pull request! We'll get to work taking a look at this today. I had a few questions on the thread for issue #276. Could you give those a quick look?

@AdamMagaluk
Copy link
Collaborator

Closing this PR, the underlying issue was fixed in #284

@ariafloat ariafloat deleted the issue276 branch January 21, 2016 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants