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


Java SerializedSubject类代码示例

本文整理汇总了Java中rx.subjects.SerializedSubject的典型用法代码示例。如果您正苦于以下问题:Java SerializedSubject类的具体用法?Java SerializedSubject怎么用?Java SerializedSubject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SerializedSubject类属于rx.subjects包,在下文中一共展示了SerializedSubject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RxBus

import rx.subjects.SerializedSubject; //导入依赖的package包/类
/**
 * 用SerializedSubject包装PublishSubject,序列化
 */
private RxBus() {
    //private final PublishSubject<Object> _bus = PublishSubject.create();

    // If multiple threads are going to emit events to this
    // then it must be made thread-safe like this instead
    _bus = new SerializedSubject<>(PublishSubject.create());
}
 
开发者ID:Sugarya,项目名称:FragmentCapsulation,代码行数:11,代码来源:RxBus.java

示例2: ObjectRequest

import rx.subjects.SerializedSubject; //导入依赖的package包/类
/**
 * Creates a new request with the given method.
 *
 * @param method the request {@link Method} to use
 * @param url    URL to fetch the Object
 * @param clazz  the Object class to return
 */
private ObjectRequest(int method, String url, Class clazz) {

    super(method, url, null);
    mClazz = clazz;
    mHasCache = BaseApplication.getVolleyCache().get(getCacheKey()) != null;
    setShouldCache(false);
    addEntryListener();
    setRetryPolicy(new DefaultRetryPolicy(DEFAULT_TIMEOUT_MS, DEFAULT_MAX_RETRIES, DEFAULT_BACKOFF_MULT));

    mSubject = new SerializedSubject<>(PublishSubject.create());
}
 
开发者ID:joy-inc,项目名称:joy-library,代码行数:19,代码来源:ObjectRequest.java

示例3: sendEvent

import rx.subjects.SerializedSubject; //导入依赖的package包/类
/**
 * Sends an event to the bus
 * <p>
 * @param  event  the event that should be broadcasted to the bus
 * @param  key  the key this event should be broadcasted to
 * @param  sendToDefaultBusAsWell  if true, all observers of the event class will receive this event as well
 */
public synchronized <T> void sendEvent(T event, Integer key, boolean sendToDefaultBusAsWell)
{
    RXBusEventIsNullException.checkEvent(event);
    RXBusKeyIsNullException.checkKey(key);

    // 1) send to key bound bus
    SerializedSubject subject = getSubject(new RXQueueKey(event.getClass(), key), false);
    // only send event, if subject exists => this means someone has at least once subscribed to it
    if (subject != null)
        subject.onNext(event);

    // 2) send to unbound bus
    if (sendToDefaultBusAsWell)
        sendEvent(event);
}
 
开发者ID:MFlisar,项目名称:RXBus,代码行数:23,代码来源:RXBus.java

示例4: getLogs

import rx.subjects.SerializedSubject; //导入依赖的package包/类
public Observable<LogRow> getLogs() {

        SerializedSubject<LogRow, LogRow> subject
                = new SerializedSubject<>(PublishSubject.create());

        ThreadFactory threadFactory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat(Example_8_Model.class.getSimpleName() + "-thread-%d").build();
        final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), threadFactory);

        IntStream.range(1, Runtime.getRuntime().availableProcessors() + 1).forEach(value -> {
            executorService.submit(() -> {
                SysOutUtils.sysout(Thread.currentThread().getName() + " will briefly start creating lots of log rows...");
                VariousUtils.sleep(1000);
                long incrementingNumber = 1;
                while (true) {
                    subject.onNext(new LogRow(
                            DateTimeFormatter.ISO_DATE_TIME.format(LocalDateTime.now()),
                            "Status " + Integer.toString(ThreadLocalRandom.current().nextInt(1, 5)),
                            "Action " + incrementingNumber + " from " + Thread.currentThread().getName()));
                }
            });
        });

        return subject;
    }
 
开发者ID:Petikoch,项目名称:Java_MVVM_with_Swing_and_RxJava_Examples,代码行数:25,代码来源:Example_8_Model.java

示例5: RxBusManager

import rx.subjects.SerializedSubject; //导入依赖的package包/类
private RxBusManager(){
        mSubject = new SerializedSubject<>(PublishSubject.create());
        mSubscriptionMap = new HashMap<>();
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:5,代码来源:RxBusManager.java

示例6: RxBus

import rx.subjects.SerializedSubject; //导入依赖的package包/类
private RxBus() {
    mSubject = new SerializedSubject<>(PublishSubject.create());
}
 
开发者ID:lai233333,项目名称:MyDemo,代码行数:4,代码来源:RxBus.java

示例7: RxBus

import rx.subjects.SerializedSubject; //导入依赖的package包/类
public RxBus() {
    bus = new SerializedSubject<>(PublishSubject.create());
}
 
开发者ID:Akari10032,项目名称:12306_Android,代码行数:4,代码来源:RxBus.java

示例8: RxBus

import rx.subjects.SerializedSubject; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @since 2016/7/5
 */
public RxBus() {
    // Subject that, once an Observer has subscribed,
    // emits all subsequently observed items to the subscriber.
    // PublishSubject is not thread-safe,
    // PublishSubject need to be converted into SerializedSubject
    this.mBus = new SerializedSubject<>(PublishSubject.create());
}
 
开发者ID:winzillion,项目名称:FluxJava,代码行数:13,代码来源:RxBus.java

示例9: observeEvent

import rx.subjects.SerializedSubject; //导入依赖的package包/类
/**
 * Get an observable that observes all events of the the class the
 * <p>
 * @param  eventClass  the class of event you want to observe
 * @return      an Observable, that will observe all events of the @param key class
 */
public synchronized <T> Observable<T> observeEvent(Class<T> eventClass)
{
    RXBusEventIsNullException.checkEvent(eventClass);

    SerializedSubject subject = getSubject(eventClass, true);
    return subject;
}
 
开发者ID:MFlisar,项目名称:RXBus,代码行数:14,代码来源:RXBus.java

示例10: getSubject

import rx.subjects.SerializedSubject; //导入依赖的package包/类
private synchronized SerializedSubject getSubject(Class<?> key, boolean createIfMissing)
{
    // 1) look if key already has a publisher subject, if so, return it
    if (mSubjectsClasses.containsKey(key))
        return mSubjectsClasses.get(key);
    // 2) else, create a new one and put it into the map
    else if (createIfMissing)
    {
        SerializedSubject subject = new SerializedSubject(PublishSubject.create());
        mSubjectsClasses.put(key, subject);
        return subject;
    }
    else
        return null;
}
 
开发者ID:MFlisar,项目名称:RXBus,代码行数:16,代码来源:RXBus.java

示例11: onCreate

import rx.subjects.SerializedSubject; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    presenter = new ListNotePresenter(Inject.get().notesStore());
    clickedNotesSubject = new SerializedSubject<>(PublishSubject.<String>create());
    setContentView(R.layout.view_listnotes);
}
 
开发者ID:vinaysshenoy,项目名称:rxtodo,代码行数:8,代码来源:ListNoteActivity.java

示例12: RxBus

import rx.subjects.SerializedSubject; //导入依赖的package包/类
private RxBus() {
    bus = new SerializedSubject<>(PublishSubject.create());
}
 
开发者ID:JasonChow1989,项目名称:SeeWeather-master,代码行数:4,代码来源:RxBus.java

示例13: RxBus

import rx.subjects.SerializedSubject; //导入依赖的package包/类
private RxBus() {
	BUS = new SerializedSubject<>(PublishSubject.create());
}
 
开发者ID:iflove,项目名称:gank-examples,代码行数:4,代码来源:RxBus.java

示例14: post

import rx.subjects.SerializedSubject; //导入依赖的package包/类
public <E> void post(E event){
    //subject.onNext(event);
    Class clazz = event.getClass();
    Subject<E,E> subject = subjectHashMap.get(clazz);
    if(subject==null){
        subject = new SerializedSubject<>(PublishSubject.<E>create());
        subjectHashMap.put(clazz,subject);
    }
    subject.onNext(event);
}
 
开发者ID:dyweb,项目名称:gitlab-android,代码行数:11,代码来源:RxBus.java

示例15: observeEvents

import rx.subjects.SerializedSubject; //导入依赖的package包/类
public <E> Observable<E> observeEvents(Class<E> eventClass) {
    Subject<E,E> subject = subjectHashMap.get(eventClass);
    if(subject==null){
        subject = new SerializedSubject<>(PublishSubject.<E>create());
        subjectHashMap.put(eventClass,subject);
    }
    if(eventClass.isAssignableFrom(UniqueEvent.class)&&subject.hasObservers()){
        return Observable.empty();//if the event should only be received by one observer
    }
    return subject.ofType(eventClass);//pass only events of specified type, filter all other
}
 
开发者ID:dyweb,项目名称:gitlab-android,代码行数:12,代码来源:RxBus.java


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