lib/features/auto-subscribe.js
function _observeSubscriptionSyncEvents(args) {
  var rtm = args.rtm;
  var filterFn = args.filterFn;

  rtm.on('subscription-created', function(subscription) {
    if (subscription.allowRead !== true) return;

    filterFn(subscription).then(function(ok) {
      if (ok) {
        rtm.subscribe({channel: subscription.channelId});
      }
    });
  });

  rtm.on('subscription-deleted', function(subscription) {
    rtm.unsubscribe({channel: subscription.channelId});
  });

  rtm.on('subscription-updated', function(subscription) {
    if (subscription.allowRead === false) {
      return rtm.unsubscribe({channel: subscription.channelId});
    }
    filterFn(subscription).then(function(ok) {
      if (ok) {
        rtm.subscribe({channel: subscription.channelId});
      }
    });
  });
}
function _observeSubscriptionSyncEvents(args) {
  var rtm = args.rtm;
  var filterFn = args.filterFn;

  rtm.on('subscription-created', function(subscription) {
    if (subscription.allowRead !== true) return;

    filterFn(subscription).then(function(ok) {
      if (ok) {
        rtm.subscribe({channel: subscription.channelId});
      }
    });
  });

  rtm.on('subscription-deleted', function(subscription) {
    rtm.unsubscribe({channel: subscription.channelId});
  });

  rtm.on('subscription-updated', function(subscription) {
    if (subscription.allowRead === false) {
      return rtm.unsubscribe({channel: subscription.channelId});
    }
    filterFn(subscription).then(function(ok) {
      if (ok) {
        rtm.subscribe({channel: subscription.channelId});
      }
    });
  });
}
function _observeSubscriptionSyncEvents ( args ) { var rtm = args . rtm ; var filterFn = args . filterFn ; rtm . on ( 'subscription-created' , function ( subscription ) { if ( subscription . allowRead !== true ) return ; filterFn ( subscription ) . then ( function ( ok ) { if ( ok ) { rtm . subscribe ( { channel : subscription . channelId } ) ; } } ) ; } ) ; rtm . on ( 'subscription-deleted' , function ( subscription ) { rtm . unsubscribe ( { channel : subscription . channelId } ) ; } ) ; rtm . on ( 'subscription-updated' , function ( subscription ) { if ( subscription . allowRead === false ) { return rtm . unsubscribe ( { channel : subscription . channelId } ) ; } filterFn ( subscription ) . then ( function ( ok ) { if ( ok ) { rtm . subscribe ( { channel : subscription . channelId } ) ; } } ) ; } ) ; }
Register event listeners for keeping subscriptions in sync.

@param {Object} args
@param {RtmClient} args.rtm
@param {Function} args.filterFn
@private
Register event listeners for keeping subscriptions in sync .