RxJavaCreate { @NonNull public static Observable<Integer> observableWithCreate() { return Observable.create(subscriber -> { subscriber.onNext(5); subscriber.onNext(10); try { Thread.sleep(300); } catch (InterruptedException e) { subscriber.onError(e); return; } if (!subscriber.isUnsubscribed()) { subscriber.onNext(15); } subscriber.onCompleted(); }); }  @NonNull static Observable<Integer> observableWithCreate(); @NonNull static Observable<Integer> from(); @NonNull static Observable<Integer> async();  }
@Test public void testObservableWithCreate() throws Exception { RxJavaCreate.observableWithCreate().subscribe(System.out::println); }
@Test public void testCreateUnsubscribed() throws Exception { Subscription subscription = RxJavaCreate.observableWithCreate() .subscribeOn(Schedulers.newThread()) .subscribe(System.out::println); subscription.unsubscribe(); }