Skip to content

v0.4.0

Compare
Choose a tag to compare
@alexander-fenster alexander-fenster released this 08 Dec 20:59
· 1164 commits to main since this release

⚠️ Breaking Changes

Promises have arrived!

Issue: #551
PR: #1702

It's been a long time coming, but we're finally here. We've shipped promise support in the Google Cloud Pub/Sub module!

Do I have to use promises?

Nope, carry on. (But keep reading if you use streams)

How do I use promises?

Don't pass a callback:

var pubsub = require('@google-cloud/pubsub')();

pubsub.getTopics()
  .then(function(data) {
    var topics = data[0];
  })
  .catch(function(err) {});

How do I use a method as a stream?

All of the streaming functionality from our methods have been moved to their own method.

var pubsub = require('@google-cloud/pubsub')();

- pubsub.getSubscriptions()
+ pubsub.getSubscriptionsStream()
    .on('data', function(subscription) {})

- pubsub.getTopics()
+ pubsub.getTopicsStream()
    .on('data', function(topic) {})
var topic = pubsub.topic('my-topic-name');

- topic.getSubscriptions()
+ topic.getSubscriptionsStream()
    .on('data', function(subscription) {})