本文整理汇总了Java中rx.subjects.Subject类的典型用法代码示例。如果您正苦于以下问题:Java Subject类的具体用法?Java Subject怎么用?Java Subject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Subject类属于rx.subjects包,在下文中一共展示了Subject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unregister
import rx.subjects.Subject; //导入依赖的package包/类
/**
* 取消监听
*
* @param tag
* @param observable
* @return
*/
@SuppressWarnings("rawtypes")
public RxBus unregister(@NonNull Object tag,
@NonNull Observable<?> observable) {
if (null == observable)
return $();
List<Subject> subjects = subjectMapper.get(tag);
if (null != subjects) {
subjects.remove((Subject<?, ?>) observable);
if (isEmpty(subjects)) {
subjectMapper.remove(tag);
LogUtil.d("unregister", tag + " size:" + subjects.size());
}
}
return $();
}
示例2: unregister
import rx.subjects.Subject; //导入依赖的package包/类
/**
* 取消监听
*
* @param tag
* @param observable
* @return
*/
@SuppressWarnings("rawtypes")
public RxBus unregister(@NonNull Object tag,
@NonNull Observable<?> observable) {
if (null == observable)
return getInstance();
List<Subject> subjects = subjectMapper.get(tag);
if (null != subjects) {
subjects.remove((Subject<?, ?>) observable);
if (isEmpty(subjects)) {
subjectMapper.remove(tag);
LogUtils.logd("unregister"+ tag + " size:" + subjects.size());
}
}
return getInstance();
}
示例3: onNext
import rx.subjects.Subject; //导入依赖的package包/类
public void onNext(T1 args) {
try {
int id;
Subject<T2, T2> subj = PublishSubject.create();
Observer<T2> subjSerial = new SerializedObserver(subj);
synchronized (ResultManager.this.guard) {
ResultManager resultManager = ResultManager.this;
id = resultManager.leftIds;
resultManager.leftIds = id + 1;
ResultManager.this.leftMap.put(Integer.valueOf(id), subjSerial);
}
Observable<T2> window = Observable.create(new WindowObservableFunc(subj, ResultManager.this.cancel));
Observable<D1> duration = (Observable) OnSubscribeGroupJoin.this.leftDuration.call(args);
Subscriber<D1> d1 = new LeftDurationObserver(id);
ResultManager.this.group.add(d1);
duration.unsafeSubscribe(d1);
R result = OnSubscribeGroupJoin.this.resultSelector.call(args, window);
synchronized (ResultManager.this.guard) {
List<T2> rightMapValues = new ArrayList(ResultManager.this.rightMap.values());
}
ResultManager.this.subscriber.onNext(result);
for (T2 t2 : rightMapValues) {
subjSerial.onNext(t2);
}
} catch (Throwable t) {
Exceptions.throwOrReport(t, this);
}
}
示例4: unregister
import rx.subjects.Subject; //导入依赖的package包/类
/**
* 取消监听
*/
@SuppressWarnings("rawtypes")
public RxBus unregister(@NonNull Object tag,
@NonNull Observable<?> observable) {
if (null == observable) {
return $();
}
List<Subject> subjects = subjectMapper.get(tag);
if (null != subjects) {
subjects.remove((Subject<?, ?>) observable);
if (isEmpty(subjects)) {
subjectMapper.remove(tag);
LogUtils.d(tag + " size:" + subjects.size());
}
}
return $();
}
示例5: build
import rx.subjects.Subject; //导入依赖的package包/类
@NonNull
public UploadManager build() {
if (uploadService == null) {
throw new IllegalArgumentException("Must provide a valid upload service");
}
if (uploadDataStore == null) {
throw new IllegalArgumentException("Must provide a valid upload data store");
}
if (uploadErrorAdapter == null) {
throw new IllegalArgumentException("Must provide a valid upload error adapter");
}
final Subject<Job, Job> jobSubject = PublishSubject.<Job>create().toSerialized();
final Subject<Status, Status> statusSubject =
PublishSubject.<Status>create().toSerialized();
final Uploader uploader = Uploader.create(uploadService);
final UploadInteractor uploadInteractor =
UploadInteractorImpl.create(uploader, uploadDataStore, uploadErrorAdapter);
return new UploadManager(uploadInteractor, uploadErrorAdapter, jobSubject,
statusSubject, deleteRecordOnComplete);
}
示例6: emitEvent
import rx.subjects.Subject; //导入依赖的package包/类
protected void emitEvent(ConfigChangeEvent<String> event)
{
checkNotNull(event);
final Optional<String> oldEventValue = this.lastEmittedValues.put(event.getName(), event.getValueOpt());
if (!event.getValueOpt().equals(oldEventValue)) {
Subject<ConfigChangeEvent<String>, ConfigChangeEvent<String>> subject = subjectMap.get(event.getName());
if (subject == null) {
log.warn("Event Subject was not initialized for key {} !", event.getName());
return;
}
log.trace("EMIT {} - value {}", event.getName(), event.getValueOpt());
subject.onNext(event);
}
else {
log.trace("NOT EMITTING key {} value {} - no change from previous value.", event.getName(), event.getValueOpt());
}
}
示例7: behaviorRefCount
import rx.subjects.Subject; //导入依赖的package包/类
@Nonnull
public static <T> Observable.Transformer<? super T, ? extends T> behaviorRefCount() {
return new Observable.Transformer<T, T>() {
@Override
public Observable<T> call(Observable<T> tObservable) {
return new OperatorMulticast<>(tObservable, new Func0<Subject<? super T, ? extends T>>() {
@Override
public Subject<? super T, ? extends T> call() {
return BehaviorSubject.<T>create();
}
}).refCount();
}
};
}
示例8: getThread
import rx.subjects.Subject; //导入依赖的package包/类
private void getThread(ExecutorService executor, Subject<Object, Object> subject) {
executor.execute(() ->
{
for (int i = 0; i < 10; i++) {
System.out.println("onNext " + i);
subject.onNext(i);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
subject.onError(e);
}
}
System.out.println("completing");
subject.onCompleted();
});
}
示例9: unregister
import rx.subjects.Subject; //导入依赖的package包/类
/**
* 取消监视,删除被监视者.
*
* @param event
* @param register
*/
public void unregister(final int event, Object register) {
String key = event + "";
String tag = getUniqueTag(event, register);
Subject subject = single_map.get(tag);
List<Subject> subjects = subject_map.get(key);
if (null != subjects) {
if (null != subject) {
subjects.remove(subject);
single_map.remove(tag);
}
if (subjects.size() == 0) {
subject_map.remove(key);
}
}
Log.i(TAG, "unregister:" + register.getClass().getSimpleName() + "," +
"single_map size:" + single_map.size() + ",subject_map size:" + subject_map.size());
}
示例10: unregister
import rx.subjects.Subject; //导入依赖的package包/类
/**
* 取消监听
*
* @param tag
* @param observable
* @return
*/
@SuppressWarnings("rawtypes")
public RxBus unregister(@NonNull Object tag,
@NonNull Observable<?> observable) {
if (null == observable)
return $();
List<Subject> subjects = subjectMapper.get(tag);
if (null != subjects) {
subjects.remove((Subject<?, ?>) observable);
if (isEmpty(subjects)) {
subjectMapper.remove(tag);
JLog.d("unregister", tag + " size:" + subjects.size());
}
}
return $();
}
示例11: Method
import rx.subjects.Subject; //导入依赖的package包/类
public Subject<R, R> Method(SD<R> body) {
depth++;
body.accept(null,
r -> {
depth--;
if (depth==0) result.onCompleted();
},
() -> {
depth--;
if (depth==0) result.onCompleted();
},
label -> { },
label -> { },
ex -> { result.onError(ex); }) ;
return result;
}
示例12: getStandardError
import rx.subjects.Subject; //导入依赖的package包/类
/**
* Get the standard error callback.
*
* @param responseEmitter Channel to send the error response to
* @param druidQuery Query for which we got an error
*
* @return the standard error callback
*/
public HttpErrorCallback getStandardError(
final Subject responseEmitter,
final DruidAggregationQuery<?> druidQuery
) {
return new HttpErrorCallback() {
@Override
public void invoke(int statusCode, String reason, String responseBody) {
LOG.error(ErrorMessageFormat.ERROR_FROM_DRUID.logFormat(responseBody, statusCode, reason, druidQuery));
responseEmitter.onError(new ResponseException(
statusCode,
reason,
responseBody,
druidQuery,
null,
getObjectMappers().getMapper().writer()
));
}
};
}
示例13: getStandardFailure
import rx.subjects.Subject; //导入依赖的package包/类
/**
* Get the standard failure callback.
*
* @param responseEmitter Channel to send the response to
* @param druidQuery Query for which we got a failure
*
* @return the standard failure callback
*/
public FailureCallback getStandardFailure(
final Subject responseEmitter,
final DruidAggregationQuery<?> druidQuery
) {
return new FailureCallback() {
@Override
public void invoke(Throwable error) {
LOG.error(ErrorMessageFormat.FAILED_TO_SEND_QUERY_TO_DRUID.logFormat(druidQuery), error);
responseEmitter.onError(new ResponseException(
Status.INTERNAL_SERVER_ERROR,
druidQuery,
error,
objectMappers.getMapper().writer()
));
}
};
}
示例14: unSubscribe
import rx.subjects.Subject; //导入依赖的package包/类
/**
* 取消监听
*
* @param tag
* @param observable
* @return
*/
@SuppressWarnings("rawtypes")
public RxBus unSubscribe(@NonNull Object tag,
@NonNull Observable<?> observable) {
if (null == observable)
return $();
List<Subject> subjects = subjectMapper.get(tag);
if (null != subjects) {
subjects.remove((Subject<?, ?>) observable);
if (isEmpty(subjects)) {
subjectMapper.remove(tag);
//LogUtils.d("unregister:"+tag + " size:" + subjects.size());
}
}
return $();
}
示例15: OperatorMulticast
import rx.subjects.Subject; //导入依赖的package包/类
private OperatorMulticast(final Object guard,
final AtomicReference<Subject<? super T, ? extends R>> connectedSubject,
final List<Subscriber<? super R>> waitingForConnect,
Observable<? extends T> source,
final Supplier<? extends Subject<? super T, ? extends R>> subjectFactory) {
super(s -> {
synchronized (guard) {
Subject<? super T, ? extends R> subject = connectedSubject.get();
if (subject == null) {
// not connected yet, so register
waitingForConnect.add(s);
} else {
subject.unsafeSubscribe(s);
}
}
});
this.guard = guard;
this.connectedSubject = connectedSubject;
this.waitingForConnect = waitingForConnect;
this.source = source;
this.subjectFactory = subjectFactory;
}