Setup subscriptions when the Observable subscription is set up.

@param subscriber the subscriber
338105
@Override
    public void call(Subscriber<? super Job<K, V>> subscriber) {

        log.debug("onSubscribe()");
        if (subscriber.isUnsubscribed()) {
            return;
        }

        String subscriberId = getClass().getSimpleName() + "-" + id + "-" + subscriberIds.incrementAndGet();
        subscriber.onStart();

        try {
            Scheduler.Worker worker = scheduler.createWorker();

            GetJobsAction<K, V> getJobsAction = new GetJobsAction<K, V>(disqueConnectionSupplier, subscriberId, subscriber,
                    jobLocalityTracking, getJobsArgs);

            actions.add(getJobsAction);
            Subscription subscription = worker.schedulePeriodically(getJobsAction, 0, 10, TimeUnit.MILLISECONDS);
            getJobsAction.setSelfSubscription(subscription);

            if (improveLocalityTimeUnit != null && improveLocalityInterval > 0 && reconnectTrigger == null) {
                reconnectTrigger = worker.schedulePeriodically(new Action0() {
                    @Override
                    public void call() {
                        switchNodes();
                    }
                }, improveLocalityInterval, improveLocalityInterval, improveLocalityTimeUnit);
            }
        } catch (Exception e) {
            if (log.isDebugEnabled()) {
                log.debug("QueueListener.call caught an exception: {}", e.getMessage(), e);
            }
            subscriber.onError(e);
        }
    }
1176133
protected <E extends Event> void subscribeEvent(Class<E> eventClass, final Listener<E> listener) {
        locator.inject(listener);
        locator.postConstruct(listener);
        subscribe(eventClass, listener);
    }
875309
def subscribe_to_events(config, subscriber, events, model=None):
    
    kwargs = {}
    if model is not None:
        kwargs['model'] = model

    for evt in events:
        config.add_subscriber(subscriber, evt, **kwargs)
723795
public <T> void adapt(@NonNull final Observable<T> subscriber, @Nullable final Callback<T> callback) {
        subscriber.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<T>() {

                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        if (callback != null) {
                            callback.error(e);
                        }
                    }

                    @Override
                    public void onNext(T result) {
                        if (callback != null) {
                            callback.success(result);
                        }
                    }
                });
    }
74318
static <T> void subscribe(Subscriber<? super T> s, Iterator<? extends T> it) {
        if (it == null) {
            error(s, new NullPointerException("The iterator is null"));
            return;
        }

        boolean b;

        try {
            b = it.hasNext();
        } catch (Throwable e) {
            error(s, e);
            return;
        }

        if (!b) {
           complete(s);
            return;
        }

        s.onSubscribe(new IterableSubscription<T>(s, it));

    }
1076279
private void doSubscribe(boolean subscribe) {
        for (String eventName : eventNames) {
            if (subscribe) {
                eventManager.subscribe(eventName, this);
            } else {
                eventManager.unsubscribe(eventName, this);
            }
        }
    }
1279056
public Set<Method> subscriptionsOn(Object subscriber) {
        SubscriptionMethodFilter filter = new SubscriptionMethodFilter();
        Class<?> subscriberClass = subscriber.getClass();
        List<Method> methods = Arrays.asList(subscriberClass.getMethods());
        Set<Method> subscriptions = new HashSet<Method>();
        for (Method method : methods) {
            if (filter.accepts(method)) {
                subscriptions.add(method);
            }
        }
        return subscriptions;
    }
81274
public function broadcast(Subscriber $subscriber, array $data): void
    {
        $this->broadcasts[$subscriber->channel] = $data;
    }
1341418
protected function _attachSubscriber(EventListenerInterface $subscriber)
    {
        foreach ((array)$subscriber->implementedEvents() as $eventKey => $function) {
            $options = [];
            $method = $function;
            if (is_array($function) && isset($function['callable'])) {
                list($method, $options) = $this->_extractCallable($function, $subscriber);
            } elseif (is_array($function) && is_numeric(key($function))) {
                foreach ($function as $f) {
                    list($method, $options) = $this->_extractCallable($f, $subscriber);
                    $this->on($eventKey, $options, $method);
                }
                continue;
            }
            if (is_string($method)) {
                $method = [$subscriber, $function];
            }
            $this->on($eventKey, $options, $method);
        }
    }
933129
private void processRow(Subscriber<? super T> subscriber) throws SQLException {
        checkSubscription(subscriber);
        if (!keepGoing)
            return;
        if (rs.next()) {
            log.trace("onNext");
            subscriber.onNext(function.call(rs));
        } else
            keepGoing = false;
    }
657660
public function addListener($category, Subscriber $subscriber)
    {
        $this->subscriptions[] = new Subscription($category, $subscriber);

        $message = sprintf(self::FMT_DBG_REG_SUBSCRIBER, get_class($subscriber), $category);
        $this->logger->debug($message);
    }
504149
public void tellSubscribers( Actor sender, String topic, Object message) {
        List<ReceiverActor> subscriber = topic2Subscriber.get(topic);
        if ( subscriber != null ) {
            subscriber.stream()
                .filter(subs -> !subs.equals(sender)) // do not receive self sent
                .forEach(subs -> subs.receiveTell(topic, message) );
        }
    }
444284
public function addSubscriber(EventSubscriberInterface $subscriber)
    {
        foreach ($subscriber->getSubscribedEvents() as $name => $params) {
            if (is_string($params)) {
                $this->addListener($name, [$subscriber, $params]);
            } elseif(is_string($params[0]) && is_numeric($params[1])) {
                $this->addListener($name, [$subscriber, $params[0]], $params[1]);
            } else {
                foreach ($params as $param) {
                    if (is_string($param)) {
                        $this->addListener($name, [$subscriber, $param]);
                    } else {
                        $this->addListener($name, [$subscriber, $param[0]], isset($param[1]) ? $param[1] : 0);
                    }
                }
            }
        }
    }
549440
public function populate()
    {
        if ($this->configurator) {
            call_user_func($this->configurator);
        }

        $this->populateListeners();
        $this->populateSubscribers();
    }
9183
private void _checkAndSubscribe(KafkaConsumer<?, ?> consumer, String topic) {
        synchronized (consumer) {
            Set<String> subscription = consumer.subscription();
            if (subscription == null || !subscription.contains(topic)) {
                consumer.subscribe(Arrays.asList(topic));
            }
        }
    }
1187346
public static <T> org.reactivestreams.Subscriber<T> toSubscriber(final rx.Subscriber<T> rxSubscriber) {
        return new SubscriberAdapter<T>(rxSubscriber);
    }
545118
public static void register(Class<? extends Event> eventClass, Subscriber subscriber) {
        CopyOnWriteArraySet<Subscriber> set = SUBSCRIBER_MAP.get(eventClass);
        if (set == null) {
            set = new CopyOnWriteArraySet<Subscriber>();
            CopyOnWriteArraySet<Subscriber> old = SUBSCRIBER_MAP.putIfAbsent(eventClass, set);
            if (old != null) {
                set = old;
            }
        }
        set.add(subscriber);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Register subscriber: {} of event: {}.", subscriber, eventClass);
        }
    }