當前位置: 首頁>>代碼示例>>Java>>正文


Java Subscriber.onNext方法代碼示例

本文整理匯總了Java中org.reactivestreams.Subscriber.onNext方法的典型用法代碼示例。如果您正苦於以下問題:Java Subscriber.onNext方法的具體用法?Java Subscriber.onNext怎麽用?Java Subscriber.onNext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.reactivestreams.Subscriber的用法示例。


在下文中一共展示了Subscriber.onNext方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fastPath

import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
@Override
void fastPath() {
    T[] arr = array;
    int f = arr.length;
    Subscriber<? super T> a = actual;

    for (int i = index; i != f; i++) {
        if (cancelled) {
            return;
        }
        T t = arr[i];
        if (t == null) {
            a.onError(new NullPointerException("array element is null"));
            return;
        } else {
            a.onNext(t);
        }
    }
    if (cancelled) {
        return;
    }
    a.onComplete();
}
 
開發者ID:akarnokd,項目名稱:RxJava3-preview,代碼行數:24,代碼來源:FlowableFromArray.java

示例2: fastPath

import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
@Override
void fastPath() {
    int f = end;
    Subscriber<? super Integer> a = actual;

    for (int i = index; i != f; i++) {
        if (cancelled) {
            return;
        }
        a.onNext(i);
    }
    if (cancelled) {
        return;
    }
    a.onComplete();
}
 
開發者ID:akarnokd,項目名稱:RxJava3-preview,代碼行數:17,代碼來源:FlowableRange.java

示例3: fastPath

import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
@Override
void fastPath() {
    long f = end;
    Subscriber<? super Long> a = actual;

    for (long i = index; i != f; i++) {
        if (cancelled) {
            return;
        }
        a.onNext(i);
    }
    if (cancelled) {
        return;
    }
    a.onComplete();
}
 
開發者ID:akarnokd,項目名稱:RxJava3-preview,代碼行數:17,代碼來源:FlowableRangeLong.java

示例4: doOnEmpty

import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
public static <T> FlowableOperator<T, T> doOnEmpty(Action
                                                           action) {
    return new FlowableOperator<T, T>() {
        @Override
        public Subscriber<? super T> apply(Subscriber<? super
                T> subscriber) throws Exception {
            return new DisposableSubscriber<T>() {
                boolean isEmpty = true;

                @Override
                public void onNext(T value) {
                    isEmpty = false;
                    subscriber.onNext(value);
                }

                @Override
                public void onError(Throwable t) {
                    subscriber.onError(t);
                }

                @Override
                public void onComplete() {
                    if (isEmpty) {
                        try {
                            action.run();
                        } catch (Exception e) {
                            onError(e);
                            return;
                        }
                    }
                    subscriber.onComplete();
                }
            };
        }
    };
}
 
開發者ID:PacktPublishing,項目名稱:Learning-RxJava,代碼行數:37,代碼來源:Ch9_9.java

示例5: apply

import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
@Override
public Subscriber<? super T> apply(final Subscriber<? super T> observer) {
    return new Subscriber<T>() {
        @Override
        public void onSubscribe(Subscription subscription) {
            if (subscribedOnce.getAndSet(true)) {
                throw new NullPointerException("You cannot directly subscribe to a gRPC service multiple times " +
                        "concurrently. Use Flowable.share() instead.");
            } else {
                observer.onSubscribe(subscription);
            }
        }

        @Override
        public void onNext(T t) {
            observer.onNext(t);
        }

        @Override
        public void onError(Throwable throwable) {
            observer.onError(throwable);
        }

        @Override
        public void onComplete() {
            observer.onComplete();
        }
    };
}
 
開發者ID:salesforce,項目名稱:reactive-grpc,代碼行數:30,代碼來源:SubscribeOnlyOnceFlowableOperator.java

示例6: onRequest

import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
@Override
protected void onRequest(long n) {
    if (!complete) {
        complete = true;
        Subscriber<? super ContentChunk> subscriber = subscriber();
        subscriber.onNext(new ContentChunk(ByteBuffer.wrap(bytes), Callback.NOOP));
        subscriber.onComplete();
    }
}
 
開發者ID:jetty-project,項目名稱:jetty-reactive-httpclient,代碼行數:10,代碼來源:StringContent.java

示例7: wrapSubscriber

import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
public static <T> Subscriber<T> wrapSubscriber(Subscriber<T> subscriber, IRxBusQueue isResumedProvider)
{
    return new Subscriber<T>()
    {
        @Override
        public void onSubscribe(Subscription s) {
            subscriber.onSubscribe(s);
        }

        @Override
        public void onComplete()
        {
            subscriber.onComplete();
        }

        @Override
        public void onError(Throwable e)
        {
            subscriber.onError(e);
        }

        @Override
        public void onNext(T t)
        {
            if (RxUtil.safetyQueueCheck(t, isResumedProvider))
                subscriber.onNext(t);
        }
    };
}
 
開發者ID:MFlisar,項目名稱:RxBus2,代碼行數:30,代碼來源:RxSubscriptionUtil.java

示例8: wrapSubscriber

import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
public static <T> Subscriber<T> wrapSubscriber(Subscriber<T> subscriber, IRxBusQueue isResumedProvider)
{
    return new Subscriber<T>()
    {
        @Override
        public void onSubscribe(Subscription s) {
            subscriber.onSubscribe(s);
        }

        @Override
        public void onComplete()
        {
            subscriber.onComplete();
        }

        @Override
        public void onError(Throwable e)
        {
            subscriber.onError(e);
        }


        @Override
        public void onNext(T t)
        {
            if (RxUtil.safetyQueueCheck(t, isResumedProvider))
                subscriber.onNext(t);
        }
    };
}
 
開發者ID:MFlisar,項目名稱:RxBus2,代碼行數:31,代碼來源:RxBusUtil.java

示例9: onNext

import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
/**
 * Emits the given value if possible and terminates if there was an onComplete or onError
 * while emitting, drops the value otherwise.
 * @param <T> the value type
 * @param subscriber the target Subscriber to emit to
 * @param value the value to emit
 * @param wip the serialization work-in-progress counter/indicator
 * @param error the holder of Throwables
 */
public static <T> void onNext(Subscriber<? super T> subscriber, T value,
        AtomicInteger wip, AtomicThrowable error) {
    if (wip.get() == 0 && wip.compareAndSet(0, 1)) {
        subscriber.onNext(value);
        if (wip.decrementAndGet() != 0) {
            Throwable ex = error.terminate();
            if (ex != null) {
                subscriber.onError(ex);
            } else {
                subscriber.onComplete();
            }
        }
    }
}
 
開發者ID:akarnokd,項目名稱:RxJava3-preview,代碼行數:24,代碼來源:HalfSerializer.java

示例10: request

import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
@Override
public void request(long n) {
    if (!SubscriptionHelper.validate(n)) {
        return;
    }
    if (compareAndSet(NO_REQUEST, REQUESTED)) {
        Subscriber<? super T> s = subscriber;

        s.onNext(value);
        if (get() != CANCELLED) {
            s.onComplete();
        }
    }

}
 
開發者ID:akarnokd,項目名稱:RxJava3-preview,代碼行數:16,代碼來源:ScalarSubscription.java

示例11: request

import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
@Override
public final void request(long n) {
    if (SubscriptionHelper.validate(n)) {
        for (;;) {
            int state = get();
            // if the any bits 1-31 are set, we are either in fusion mode (FUSED_*)
            // or request has been called (HAS_REQUEST_*)
            if ((state & ~NO_REQUEST_HAS_VALUE) != 0) {
                return;
            }
            if (state == NO_REQUEST_HAS_VALUE) {
                if (compareAndSet(NO_REQUEST_HAS_VALUE, HAS_REQUEST_HAS_VALUE)) {
                    T v = value;
                    if (v != null) {
                        value = null;
                        Subscriber<? super T> a = actual;
                        a.onNext(v);
                        if (get() != CANCELLED) {
                            a.onComplete();
                        }
                    }
                }
                return;
            }
            if (compareAndSet(NO_REQUEST_NO_VALUE, HAS_REQUEST_NO_VALUE)) {
                return;
            }
        }
    }
}
 
開發者ID:akarnokd,項目名稱:RxJava3-preview,代碼行數:31,代碼來源:DeferredScalarSubscription.java

示例12: slowPath

import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
@Override
void slowPath(long r) {
    long e = 0;
    int f = end;
    int i = index;
    Subscriber<? super Integer> a = actual;

    for (;;) {

        while (e != r && i != f) {
            if (cancelled) {
                return;
            }

            a.onNext(i);

            e++;
            i++;
        }

        if (i == f) {
            if (!cancelled) {
                a.onComplete();
            }
            return;
        }

        r = get();
        if (e == r) {
            index = i;
            r = addAndGet(-e);
            if (r == 0L) {
                return;
            }
            e = 0L;
        }
    }
}
 
開發者ID:akarnokd,項目名稱:RxJava3-preview,代碼行數:39,代碼來源:FlowableRange.java

示例13: slowPath

import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
@Override
void slowPath(long r) {
    long e = 0;
    long f = end;
    long i = index;
    Subscriber<? super Long> a = actual;

    for (;;) {

        while (e != r && i != f) {
            if (cancelled) {
                return;
            }

            a.onNext(i);

            e++;
            i++;
        }

        if (i == f) {
            if (!cancelled) {
                a.onComplete();
            }
            return;
        }

        r = get();
        if (e == r) {
            index = i;
            r = addAndGet(-e);
            if (r == 0L) {
                return;
            }
            e = 0L;
        }
    }
}
 
開發者ID:akarnokd,項目名稱:RxJava3-preview,代碼行數:39,代碼來源:FlowableRangeLong.java

示例14: subscribe

import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
@Override
public void subscribe(Subscriber<? super Object>[] subscribers) {
    TestException ex = new TestException();
    for (Subscriber<? super Object> s : subscribers) {
        EmptySubscription.error(ex, s);
        s.onError(ex);
        s.onNext(0);
        s.onComplete();
        s.onComplete();
    }
}
 
開發者ID:akarnokd,項目名稱:RxJava3-preview,代碼行數:12,代碼來源:ParallelInvalid.java

示例15: slowPath

import org.reactivestreams.Subscriber; //導入方法依賴的package包/類
@Override
void slowPath(long r) {
    long e = 0;
    T[] arr = array;
    int f = arr.length;
    int i = index;
    Subscriber<? super T> a = actual;

    for (;;) {

        while (e != r && i != f) {
            if (cancelled) {
                return;
            }

            T t = arr[i];

            if (t == null) {
                a.onError(new NullPointerException("array element is null"));
                return;
            } else {
                a.onNext(t);
            }

            e++;
            i++;
        }

        if (i == f) {
            if (!cancelled) {
                a.onComplete();
            }
            return;
        }

        r = get();
        if (e == r) {
            index = i;
            r = addAndGet(-e);
            if (r == 0L) {
                return;
            }
            e = 0L;
        }
    }
}
 
開發者ID:akarnokd,項目名稱:RxJava3-preview,代碼行數:47,代碼來源:FlowableFromArray.java


注:本文中的org.reactivestreams.Subscriber.onNext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。