本文整理汇总了Java中rx.subscriptions.BooleanSubscription类的典型用法代码示例。如果您正苦于以下问题:Java BooleanSubscription类的具体用法?Java BooleanSubscription怎么用?Java BooleanSubscription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BooleanSubscription类属于rx.subscriptions包,在下文中一共展示了BooleanSubscription类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: call
import rx.subscriptions.BooleanSubscription; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void call(final Subscriber<? super T> subscriber) {
final PropertyChangeListener changeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (!subscriber.isUnsubscribed() && property.equals(event.getPropertyName())) {
subscriber.onNext((T) event.getNewValue());
}
}
};
propertyChangeSupport.addPropertyChangeListener(changeListener);
subscriber.add(BooleanSubscription.create(new Action0() {
@Override
public void call() {
propertyChangeSupport.removePropertyChangeListener(changeListener);
}
}));
}
开发者ID:ffgiraldez,项目名称:rx-mvvm-android,代码行数:21,代码来源:PropertyChangeListenerOnSubscribe.java
示例2: getState
import rx.subscriptions.BooleanSubscription; //导入依赖的package包/类
private Observable<ManagedState> getState(final Id id) {
return Observable.create(new Observable.OnSubscribe<ManagedState>() {
@Override
public void call(final Subscriber<? super ManagedState> subscriber) {
final ManagedState state = state(id, true);
subscriber.add(BooleanSubscription.create(new Action0() {
@Override
public void call() {
state.removeSubscriber(subscriber);
}
}));
int publishCount = state.publishCount;
state.addSubscriber(subscriber);
// check to avoid double-publishing
if (publishCount == state.publishCount) {
subscriber.onNext(state);
}
}
});
}
开发者ID:nextopio,项目名称:nextop-client,代码行数:23,代码来源:RxManager.java
示例3: call
import rx.subscriptions.BooleanSubscription; //导入依赖的package包/类
@Override
public void call(Subscriber<? super T> subscriber) {
final ValueEventListener eventListener = query.addValueEventListener(new RxValueListener<>(subscriber, marshaller));
subscriber.add(BooleanSubscription.create(new Action0() {
@Override
public void call() {
query.removeEventListener(eventListener);
}
}));
}
开发者ID:marcovann,项目名称:Firebase-Chat-Demo,代码行数:11,代码来源:ListenToValueEventsOnSubscribe.java
示例4: clearOnUnsubscribe
import rx.subscriptions.BooleanSubscription; //导入依赖的package包/类
private AddUnsubscribe clearOnUnsubscribe(final Object observable) {
return new AddUnsubscribe(
BooleanSubscription.create(
new Action0() {
@Override
public void call() {
mapSubject.get(observable).first.clear();
}
}
)
);
}
开发者ID:novoda,项目名称:rxpresso,代码行数:13,代码来源:RxMock.java
示例5: outSubscription
import rx.subscriptions.BooleanSubscription; //导入依赖的package包/类
public Subscription outSubscription() {
return BooleanSubscription.create(new Action0() {
@Override
public void call() {
unsubscribe();
subscribers = subscribers.removing(Bridge.this);
}
});
}
开发者ID:nextopio,项目名称:nextop-client,代码行数:10,代码来源:RxLifecycleBinder.java
示例6: InnerImmediateScheduler
import rx.subscriptions.BooleanSubscription; //导入依赖的package包/类
private InnerImmediateScheduler() {
this.innerSubscription = new BooleanSubscription();
}
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:ImmediateScheduler.java
示例7: InnerCurrentThreadScheduler
import rx.subscriptions.BooleanSubscription; //导入依赖的package包/类
private InnerCurrentThreadScheduler() {
this.counter = new AtomicInteger();
this.queue = new PriorityBlockingQueue();
this.innerSubscription = new BooleanSubscription();
this.wip = new AtomicInteger();
}
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:7,代码来源:TrampolineScheduler.java
示例8: InnerTestScheduler
import rx.subscriptions.BooleanSubscription; //导入依赖的package包/类
private InnerTestScheduler() {
this.s = new BooleanSubscription();
}
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:TestScheduler.java
示例9: testCustomObservableWithErrorInObserverAsynchronous
import rx.subscriptions.BooleanSubscription; //导入依赖的package包/类
/**
* The error from the user provided Observer is not handled by the subscribe method try/catch.
*
* It is handled by the AtomicObserver that wraps the provided Observer.
*
* Result: Passes (if AtomicObserver functionality exists)
*/
@Test
public void testCustomObservableWithErrorInObserverAsynchronous() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final AtomicInteger count = new AtomicInteger();
final AtomicReference<Throwable> error = new AtomicReference<Throwable>();
Observable.create(new OnSubscribe<String>() {
@Override
public void call(final Subscriber<? super String> observer) {
final BooleanSubscription s = new BooleanSubscription();
new Thread(new Runnable() {
@Override
public void run() {
try {
if (!s.isUnsubscribed()) {
observer.onNext("1");
observer.onNext("2");
observer.onNext("three");
observer.onNext("4");
observer.onComplete();
}
} finally {
latch.countDown();
}
}
}).start();
}
}).subscribe(new Subscriber<String>() {
@Override
public void onComplete() {
System.out.println("completed");
}
@Override
public void onError(Throwable e) {
error.set(e);
System.out.println("error");
e.printStackTrace();
}
@Override
public void onNext(String v) {
int num = Integer.parseInt(v);
System.out.println(num);
// doSomething(num);
count.incrementAndGet();
}
});
// wait for async sequence to complete
latch.await();
assertEquals(2, count.get());
assertNotNull(error.get());
if (!(error.get() instanceof NumberFormatException)) {
fail("It should be a NumberFormatException");
}
}
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:68,代码来源:ObservableTests.java
示例10: testCustomObservableWithErrorInObserverAsynchronous
import rx.subscriptions.BooleanSubscription; //导入依赖的package包/类
/**
* The error from the user provided Observer is not handled by the subscribe method try/catch.
*
* It is handled by the AtomicObserver that wraps the provided Observer.
*
* Result: Passes (if AtomicObserver functionality exists)
*/
@Test
public void testCustomObservableWithErrorInObserverAsynchronous() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final AtomicInteger count = new AtomicInteger();
final AtomicReference<Throwable> error = new AtomicReference<Throwable>();
Observable.create(new OnSubscribeFunc<String>() {
@Override
public Subscription onSubscribe(final Observer<? super String> observer) {
final BooleanSubscription s = new BooleanSubscription();
new Thread(new Runnable() {
@Override
public void run() {
try {
if (!s.isUnsubscribed()) {
observer.onNext("1");
observer.onNext("2");
observer.onNext("three");
observer.onNext("4");
observer.onCompleted();
}
} finally {
latch.countDown();
}
}
}).start();
return s;
}
}).subscribe(new Subscriber<String>() {
@Override
public void onCompleted() {
System.out.println("completed");
}
@Override
public void onError(Throwable e) {
error.set(e);
System.out.println("error");
e.printStackTrace();
}
@Override
public void onNext(String v) {
int num = Integer.parseInt(v);
System.out.println(num);
// doSomething(num);
count.incrementAndGet();
}
});
// wait for async sequence to complete
latch.await();
assertEquals(2, count.get());
assertNotNull(error.get());
if (!(error.get() instanceof NumberFormatException)) {
fail("It should be a NumberFormatException");
}
}
开发者ID:houdejun214,项目名称:lakeside-java,代码行数:69,代码来源:ObservableTests.java
注:本文中的rx.subscriptions.BooleanSubscription类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论