/** * Creates a {@link ClearableBehaviorSubject} without a default item. * * @param <T> * the type of item the Subject will emit * @return the constructed {@link ClearableBehaviorSubject} */ public static <T> ClearableBehaviorSubject<T> create() { return create(null, false); } /**
/** * Creates a {@link ClearableBehaviorSubject} that emits the last item it observed and all subsequent items to each * {@link rx.Observer} that subscribes to it. * * @param <T> * the type of item the Subject will emit * @param defaultValue * the item that will be emitted first to any {@link rx.Observer} as long as the * {@link ClearableBehaviorSubject} has not yet observed any items from its source {@code Observable} * @return the constructed {@link ClearableBehaviorSubject} */ public static <T> ClearableBehaviorSubject<T> create(T defaultValue) { return create(defaultValue, true); } private static <T> ClearableBehaviorSubject<T> create(T defaultValue, boolean hasDefault) {
private void initialiseMockedObservable(Method method, Object[] args) { ClearableBehaviorSubject<Notification> subject = ClearableBehaviorSubject.create(); PublishSubject<Notification> notificationSubject = PublishSubject.create(); final String keyForArgs = getKeyFor(method, args); final Observable observable = subject .dematerialize() .doOnEach(new NotifyDataEvent(notificationSubject)) .lift(new SwallowUnsubscribe()); observableHashMap.put(keyForArgs, observable); mapSubject.put(observable, new Pair<>(subject, notificationSubject)); }