We have released a new version of our Stream JavaScript client.
This version adds support for new Stream API features, reduces the size of the distributable JavaScript file, creates library documentation pages, and improves browser compatibility of our client.
Continue reading to find out about all new features introduced in this release.
Promises
All methods that perform an asynchronous request to the Stream API now return a promise. These promises help you avoid "callback hell" and chain API calls. If you've never heard about promises read this article on HTLM5 Rocks. Promises allow us to chain two asynchronous calls after eachother while only handling errors at the end of the promise chain, instead of nesting within callbacks.
Callbacks are still supported but the XHR Request object can no longer be manipulated since it is not returned.
The error object supplied to an error handler contains two properties: the response object created by the XHRRequest and an error object with additional information on the origin of the failure.
Batch Operations
Two new API features for batch operations have been added to the client. First it is now possible to add one activity to multiple feeds through a single API call, with the method addToMany on the client object. The second batch operation allows you to create multiple follow relations through the use of followMany.
To create multiple follow relations within a single api call, use the followMany function of client.
Copy Limit
If you want to create a follow relation without copying the history of the target feed, this is now possible through the use of 'activity_copy_limit' API feature.
Expire Tokens
When connecting to stream through .connect you can supply additional arguments in the fourth parameter. It is now possible to enable expiration of tokens generated by the stream client. The default behaviour is to never expire the generated tokens.