/** * Creates a bounded replay subject with the given state shared between the subject and the * {@link OnSubscribe} functions. * * @param <T> * the type of items observed and emitted by the Subject * @param state * the shared state * @return the created subject */ static final <T> ReplaySubject<T> createWithState(final BoundedState<T> state, Action1<SubjectObserver<T>> onStart) { SubjectSubscriptionManager<T> ssm = new SubjectSubscriptionManager<T>(); ssm.onStart = onStart; ssm.onTerminated = new Action1<SubjectObserver<T>>() { @Override public void call(SubjectObserver<T> t1) { NodeList.Node<Object> l = t1.index(); if (l == null) { l = state.head(); } state.replayObserverFromIndex(l, t1); } }; return new ReplaySubject<T>(ssm, ssm, state); }
return new ReplaySubject<T>(ssm, ssm, state);