Janishar Ali
Jul 23, 2017 · 1 min read

Vladimir Chernis Yes the hot publishers start emitting item immediately after they are created.

Example:

Subject<Integer> subject = PublishSubject.create();
subject.onNext(0);
subject.onNext(1);

subject.subscribe(
val -> System.out.println("Subscriber1 received " + val),
err -> System.out.println("error"),
() -> System.out.println("complete"));

subject.onNext(2);
subject.onNext(3);
subject.onComplete();

OUTPUT:

Subscriber received 2
Subscriber received 3
complete

    Janishar Ali

    Written by

    IIT | Co-Founder @ MindOrks | Building AfterAcademy | Code.all() | Disrupting EdTech | #MakeEveryoneCode | Now I only write at https://blog.mindorks.com

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade