当前位置: 首页>>代码示例>>Java>>正文


Java Subject类代码示例

本文整理汇总了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 $();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:RxBus.java

示例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();
}
 
开发者ID:wp521,项目名称:MyFire,代码行数:23,代码来源:RxBus.java

示例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);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:29,代码来源:OnSubscribeGroupJoin.java

示例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 $();
}
 
开发者ID:MixAndroid,项目名称:MixUtils,代码行数:20,代码来源:RxBus.java

示例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);
}
 
开发者ID:jsaund,项目名称:RxUploader,代码行数:27,代码来源:UploadManager.java

示例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());
    }
}
 
开发者ID:kikinteractive,项目名称:ice,代码行数:19,代码来源:AbstractDynamicConfigSource.java

示例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();
        }
    };
}
 
开发者ID:erlymon,项目名称:erlymon-monitor-android,代码行数:17,代码来源:MoreObservables.java

示例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();
  });
}
 
开发者ID:vgrazi,项目名称:rxjava-snippets,代码行数:17,代码来源:GeneralCodeSamples.java

示例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());
}
 
开发者ID:huscarter,项目名称:RxBusDemo,代码行数:24,代码来源:RxBus.java

示例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 $();
}
 
开发者ID:Freelander,项目名称:Elephant,代码行数:23,代码来源:RxBus.java

示例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;
}
 
开发者ID:cwi-swat,项目名称:recaf,代码行数:17,代码来源:StreamExt.java

示例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()
            ));
        }
    };
}
 
开发者ID:yahoo,项目名称:fili,代码行数:28,代码来源:MappingResponseProcessor.java

示例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()
            ));
        }
    };
}
 
开发者ID:yahoo,项目名称:fili,代码行数:26,代码来源:MappingResponseProcessor.java

示例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 $();
}
 
开发者ID:JoeSteven,项目名称:Zatuji,代码行数:23,代码来源:RxBus.java

示例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;
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:23,代码来源:OperatorMulticast.java


注:本文中的rx.subjects.Subject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。