Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Provision Should Return Existing Device #9

Open
wooliet opened this issue Sep 13, 2017 · 0 comments
Open

Provision Should Return Existing Device #9

wooliet opened this issue Sep 13, 2017 · 0 comments

Comments

@wooliet
Copy link

wooliet commented Sep 13, 2017

The "good" path for Scout.prototype.provision returns the device instance. However, if the instance already exists, the result is null.

Is there a good reason for that? Feels weird to assume "success" if result is null or a returned device instance.

  // if already initiated on runtime do not create a second instnace
  if(this.server._jsDevices[deviceObject.id]) {
    return null;
  }

I'm asking because I'm in a situation where it looks like I have a false result (don't know for sure if null though) and so reach into _jsDevices for the device instance, and that is also falsey.

dev = self.provision(serverQueryResult, device, parameters);
if(!dev) {
  dev = self.server._jsDevices[result.id];
}
...
if(dev) {
 // success
} else {
  // CODE REACHES HERE
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant