The listeners are subscribed to the store instead of history
768816
function listen(listener) {
      // Copy of last location.
      var lastPublishedLocation = getLocationInStore(true);

      // Keep track of whether we unsubscribed, as Redux store
      // only applies changes in subscriptions on next dispatch
      var unsubscribed = false;
      var unsubscribeFromStore = store.subscribe(function () {
        var currentLocation = getLocationInStore(true);
        if (currentLocation === lastPublishedLocation) {
          return;
        }
        lastPublishedLocation = currentLocation;
        if (!unsubscribed) {
          listener(lastPublishedLocation);
        }
      });

      // History 2.x listeners expect a synchronous call. Make the first call to the
      // listener after subscribing to the store, in case the listener causes a
      // location change (e.g. when it redirects)
      if (!history.getCurrentLocation) {
        listener(lastPublishedLocation);
      }

      // Let user unsubscribe later
      return function () {
        unsubscribed = true;
        unsubscribeFromStore();
      };
    }
632013
function subscribe() {
  console.log('Subscribing client ' + clientId + ' to topic: ' + topics.subscribe);
  client.subscribe(topics.subscribe);
  isSubscribed = true;
}
707435
public void addTangoUserListener(ITangoUserListener listener, boolean stateless)
                throws DevFailed
    {
		event_listeners.add(ITangoUserListener.class, listener);
        event_identifier = subscribe_user_event(attr_name, filters, stateless);
    }
565549
public void startSetup(@NotNull final OnIabSetupFinishedListener listener) {
        if (options != null) {
            Logger.d("startSetup() options = ", options);
        }
        //noinspection ConstantConditions
        if (listener == null) {
            throw new IllegalArgumentException("Setup listener must be not null!");
        }
        if (setupState != SETUP_RESULT_NOT_STARTED && setupState != SETUP_RESULT_FAILED) {
            throw new IllegalStateException("Couldn't be set up. Current state: " + setupStateToString(setupState));
        }
        setupState = SETUP_IN_PROGRESS;
        setupExecutorService = Executors.newSingleThreadExecutor();

        // Compose full list of available stores to check billing for
        availableAppstores.clear();
        // Add all manually supplied Appstores
        availableAppstores.addAll(options.getAvailableStores());
        final List<String> storeNames = new ArrayList<String>(options.getAvailableStoreNames());
        // Remove already added stores
        for (final Appstore appstore : availableAppstores) {
            storeNames.remove(appstore.getAppstoreName());
        }
        // Instantiate and add all known wrappers
        final List<Appstore> instantiatedAppstores = new ArrayList<Appstore>();
        for (final String storeName : options.getAvailableStoreNames()) {
            if (appStoreFactoryMap.containsKey(storeName)) {
                final Appstore appstore = appStoreFactoryMap.get(storeName).get();
                instantiatedAppstores.add(appstore);
                availableAppstores.add(appstore);
                storeNames.remove(storeName);
            }
        }
        // Look among open stores for specified store names
        if (!storeNames.isEmpty()) {
            discoverOpenStores(new OpenStoresDiscoveredListener() {
                @Override
                public void openStoresDiscovered(@NotNull final List<Appstore> appStores) {
                    // Add all specified open stores
                    for (final Appstore appstore : appStores) {
                        final String name = appstore.getAppstoreName();
                        if (storeNames.contains(name)) {
                            availableAppstores.add(appstore);
                        } else {
                            final AppstoreInAppBillingService billingService;
                            if ((billingService = appstore.getInAppBillingService()) != null) {
                                billingService.dispose();
                                Logger.d("startSetup() billing service disposed for ", appstore.getAppstoreName());
                            }
                        }
                    }
                    final Runnable cleanup = new Runnable() {
                        @Override
                        public void run() {
                            for (final Appstore appstore : instantiatedAppstores) {
                                final AppstoreInAppBillingService billingService;
                                if ((billingService = appstore.getInAppBillingService()) != null) {
                                    billingService.dispose();
                                    Logger.d("startSetup() billing service disposed for ", appstore.getAppstoreName());
                                }
                            }
                        }
                    };
                    if (setupState != SETUP_IN_PROGRESS) {
                        cleanup.run();
                        return;
                    }
                    setupWithStrategy(new OnIabSetupFinishedListener() {
                        @Override
                        public void onIabSetupFinished(final IabResult result) {
                            listener.onIabSetupFinished(result);
                            instantiatedAppstores.remove(OpenIabHelper.this.appstore);
                            cleanup.run();
                        }
                    });
                }
            });
        } else {
            setupWithStrategy(listener);
        }
    }
708892
function unsubscribe() {
    var _this = this;
    var dataBindings = Reflect.getMetadata(constance_1.STATEX_DATA_BINDINGS_KEY, this);
    if (dataBindings != undefined) {
        var subscriptions = dataBindings.subscriptions || [];
        subscriptions.forEach(function (item) { return item.target === _this && item.subscription != undefined && item.subscription.unsubscribe(); });
        dataBindings.subscriptions = subscriptions.filter(function (item) { return item.target !== _this; });
        Reflect.defineMetadata(constance_1.STATEX_DATA_BINDINGS_KEY, dataBindings, this);
    }
}
1268624
function onStorageResponse (
  error, record, recordName, socketWrapper, onComplete, onError, options, context, metaData
) {
  if (error) {
    sendError(
      C.EVENT.RECORD_LOAD_ERROR,
      `error while loading ${recordName} from storage:${error.toString()}`,
      recordName,
      socketWrapper,
      onError,
      options,
      context,
      metaData
    )
  } else {
    onComplete.call(context, record || null, recordName, socketWrapper)

    if (record) {
      options.cache.set(recordName, record, () => {}, metaData)
    }
  }
}
385458
function removeCurrentTimeSubscription(catalogItem) {
  if (defined(catalogItem._removeCurrentTimeChange)) {
    catalogItem._removeCurrentTimeChange();
    catalogItem._removeCurrentTimeChange = undefined;
  }
}
262106
@Override
	public void registerConsumer(LocalMessageConsumer consumer)
    {
        super.registerConsumer(consumer);
        
        subscriptionsLock.writeLock().lock();
        try
		{
        	LocalTopicSubscription subscription = subscriptionMap.remove(consumer.getSubscriberId());
        	if (subscription == null)
        	{
        		// New subscription
        		storeNewSubscription(consumer);
        	}
        	else
        	{
        		// Remove old subscription
        		removeSubscription(subscription);
        		// Replace by new subscription
        		storeNewSubscription(consumer);
        	}
		}
        finally
        {
        	subscriptionsLock.writeLock().unlock();
        }
    }
1232219
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});
      }
    });
  });
}
219878
private void notifyListeners(List<PipelineTimelineEntry> newEntries) {
        Map<CaseInsensitiveString, PipelineTimelineEntry> pipelineToOldestEntry = new HashMap<>();
        for (PipelineTimelineEntry challenger : newEntries) {
            CaseInsensitiveString pipelineName = new CaseInsensitiveString(challenger.getPipelineName());
            PipelineTimelineEntry champion = pipelineToOldestEntry.get(pipelineName);
            if (champion == null || challenger.compareTo(champion) < 0) {
                pipelineToOldestEntry.put(pipelineName, challenger);
            }
        }

        for (TimelineUpdateListener listener : listeners) {
            for (Map.Entry<CaseInsensitiveString, PipelineTimelineEntry> entry : pipelineToOldestEntry.entrySet()) {
                try {
                    listener.added(entry.getValue(), naturalOrderPmm.get(entry.getKey()));
                } catch (Exception e) {
                    LOGGER.warn("Ignoring exception when notifying listener: {}", listener, e);
                }
            }
        }
    }
724300
@Override
	public void removeBySubscriptionStatus(int subscriptionStatus) {
		for (CommerceSubscriptionEntry commerceSubscriptionEntry : findBySubscriptionStatus(
				subscriptionStatus, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
			remove(commerceSubscriptionEntry);
		}
	}
562662
void addChronoChangedListener(Consumer<Chronology> listener) {
        if (chronoListeners == null) {
            chronoListeners = new ArrayList<Consumer<Chronology>>();
        }
        chronoListeners.add(listener);
    }
184019
function(sEntityType, sEntityId, bShouldStoreToHistory) {
				this._oRouter.stop();
				this._oRouter.navTo("apiId", {
					id: encodeURIComponent(this._sTopicId),
					entityType: sEntityType,
					entityId: encodeURIComponent(sEntityId)
				}, !bShouldStoreToHistory);
				this._oRouter.initialize(true);
			}
1099894
function autoSubscribe(args) {
  var rtm = args.rtm;
  var listSubscriptions = args.listSubscriptions;
  var filterFn = args.filterFn || _autoSubscribeDefaultFilterFn;
  var subscriptionLoadLimit = 50;

  _observeSubscriptionSyncEvents({
    rtm: rtm,
    filterFn: filterFn
  });

  return listSubscriptions({limit: subscriptionLoadLimit}).then(function(list) {
    return _fetchAllReadSubscriptions({
      list: list,
      loadMore: listSubscriptions,
      batchSize: subscriptionLoadLimit
    }).then(function(fetchedSubscriptions) {
      var subscriptions = Array.prototype.concat.apply(
        [],
        fetchedSubscriptions
      );
      return Promise.all(subscriptions.map(filterFn)).then(function(
        filterResults
      ) {
        var promisedSubscriptions = [];
        filterResults.forEach(function(canSubscribe, subscriptionIndex) {
          if (canSubscribe) {
            promisedSubscriptions.push(
              rtm.subscribe({
                channel: subscriptions[subscriptionIndex].channelId
              })
            );
          }
        });

        return Promise.all(promisedSubscriptions);
      });
    });
  });
}
1254738
protected void subscriptionResponseReceived(IoSession session,
			SubscriptionMessage subscriptionMessage) {
		log.info("Received {}", subscriptionMessage);
		this.receivedSubscription = subscriptionMessage;

		if (this.sentSubscription == null) {
			log.error(
					"Protocol error: Received a subscription response without sending a request.\n{}",
					subscriptionMessage);
			this._disconnect();
			return;
		}

		if (!this.sentSubscription.equals(this.receivedSubscription)) {
			log.info(
					"Server did not fully accept subscription request.\nOriginal:\n{}\nAmended\n{}",
					this.sentSubscription, this.receivedSubscription);
		}

		for (ConnectionListener listener : this.connectionListeners) {
			listener.subscriptionReceived(this, subscriptionMessage);
		}
	}
905780
function(client, subscriptions, backlog, channel, callback, done_callback) {
    if ( addToBacklog(client, backlog, unsubscribeBrowser, [client, subscriptions, backlog, channel, callback, done_callback]) ) return;
    if (subscriptions[channel]===undefined)
        return;
    subscriptions[channel].splice(subscriptions[channel].indexOf(callback), 1);
    if (subscriptions[channel].length===0) {
        delete subscriptions[channel];
        client.unsubscribe(channel, {onSuccess : function() {
            // If there is a done_callback defined, execute it
            if (done_callback!==undefined) done_callback();
        }});
    }
}
331406
function(subscriptions){
      if (subscriptions) _.extend(this.subscriptions || {}, subscriptions);
      subscriptions = subscriptions || this.subscriptions;
      if (!subscriptions || _.isEmpty(subscriptions)) return;
      // Just to be sure we don't set duplicate
      this.unsetSubscriptions(subscriptions);

      _.each(subscriptions, function(subscription, channel){
        var once;
        if (subscription.$once) {
          subscription = subscription.$once;
          once = true;
        }
        if (_.isString(subscription)) {
          subscription = this[subscription];
        }
        Backbone.Mediator.subscribe(channel, subscription, this, once);
      }, this);
    }