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

[enterprise] Backwards compatibility issue incoming data #8

Open
troykelly opened this issue Apr 23, 2014 · 2 comments
Open

[enterprise] Backwards compatibility issue incoming data #8

troykelly opened this issue Apr 23, 2014 · 2 comments

Comments

@troykelly
Copy link

On the production client, it has been necessary to convert incoming data to JSON for handling inside the .write function. eg

Device.prototype.write = function (data) {
var self = this;
data = JSON.parse(data);
// I'm being actuated with data!

However, this generates an error on the new enterprise client, given that "data" is already an object.

My work around to make the driver valid on both platforms is:

Device.prototype.write = function (data) {
var self = this;
if (Object.prototype.toString.call(data) != "[object Object]") { data = JSON.parse(data); }
// I'm being actuated with data!

@elliots
Copy link
Member

elliots commented Apr 23, 2014

My thinking was that the old way was wrong, and we'd just have to adjust the drivers, just how you'd suggested. That said, i could also catch the json parse exception and send in a string instead =)

@troykelly
Copy link
Author

I agree that the old way is improved here.

I guess it is a matter of communicating that change?

At the moment, the error causes the driver to fail completely - so that's probably a poor user experience.

Catching the exception would probably be a good idea, but that may introduce a "lazy" response and result in drivers that rely on the exception being caught.

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

No branches or pull requests

2 participants