當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。