Skip to content

[0.9.0] "Error-first" style callbacks. Remove deprecated device format

Latest
Compare
Choose a tag to compare
@RobAtticus RobAtticus released this 26 May 19:01
· 15 commits to master since this release

Error first callbacks

This release is not backwards compatible with previous releases when it comes to using callbacks. The library has been updated to use the "error first" convention, where the first argument to a callback is any error, and a null or undefined value implies the operation was a success.

For register():

var dev = new iobeam.Device("foo");

// pre-v0.9.0 way:
iobeamClient.register(dev, function(success, device, error) {
    if (!success) {
        console.warn(error);
    }
});

// NEW way:
iobeamClient.register(dev, function(error, device) {
    if (error) {
        console.warn(error);
    }
});

For send():

// pre-v0.9.0 way:
iobeamClient.send(function(success, store, error) {
    if (!success) {
        console.warn(error);
    }
});

// NEW way:
iobeamClient.send(dev, function(error, store) {
    if (error) {
        console.warn(error);
    }
});

Deprecation

The value passed to register() callbacks as the device parameter no longer has the following properties: device_id, device_name, device_type, or created. Instead, since it is an iobeam.Device object, use the getter methods: getId(), getName(), getType(), and getCreated().