Source:
<code>protected void subscribeToDataStoreInternal(CompositeSubscription compositeSubscription) { Log.v(TAG, "subscribeToDataStoreInternal"); ConnectableObservable<DataStreamNotification<GitHubRepositorySearch>> repositorySearchSource = Observable.switchOnNext(searchString) .filter((string) -> string.length() > 2) .throttleLast(500, TimeUnit.MILLISECONDS) .switchMap(getGitHubRepositorySearch::call) .publish(); <START> compositeSubscription.add(repositorySearchSource.connect()); <END> compositeSubscription.add( repositorySearchSource .subscribe(notification -> { if (notification.isFetchingStart()) { networkRequestStatusText.onNext("Loading.."); } else if (notification.isFetchingError()) { networkRequestStatusText.onNext("Error occured"); } else { networkRequestStatusText.onNext(""); } })); compositeSubscription.add( repositorySearchSource .filter(DataStreamNotification::isOnNext) .map(DataStreamNotification::getValue) .flatMap((repositorySearch) -> { Log.d(TAG, "Found " + repositorySearch.getItems().size() + " repositories with search " + repositorySearch.getSearch()); final List<Observable<GitHubRepository>> observables = new ArrayList<>(); for (int repositoryId : repositorySearch.getItems()) { Log.v(TAG, "Process repositoryId: " + repositoryId); final Observable<GitHubRepository> observable = getGitHubRepository.call(repositoryId) .doOnNext((repository) -> Log.v(TAG, "Received repository " + repository.getId())); observables.add(observable); if (observables.size() >= MAX_REPOSITORIES_DISPLAYED) { break; } } return Observable.combineLatest( observables, (args) -> { Log.v(TAG, "Combine items into a list"); final List<GitHubRepository> list = new ArrayList<>(); for (Object repository : args) { list.add((GitHubRepository) repository); } return list; } ); }) .subscribe((repositories) -> { Log.d(TAG, "Publishing " + repositories.size() + " repositories from the ViewModel"); RepositoriesViewModel.this.repositories.onNext(repositories); })); }</code><technical_language>connect observers subscribed</technical_language>

Target:
protected void subscribeToDataStoreInternal(CompositeSubscription compositeSubscription) { Log.v(TAG, "subscribeToDataStoreInternal"); ConnectableObservable<DataStreamNotification<GitHubRepositorySearch>> repositorySearchSource = Observable.switchOnNext(searchString) .filter((string) -> string.length() > 2) .throttleLast(500, TimeUnit.MILLISECONDS) .switchMap(getGitHubRepositorySearch::call) .publish(); compositeSubscription.add( repositorySearchSource .subscribe(notification -> { if (notification.isFetchingStart()) { networkRequestStatusText.onNext("Loading.."); } else if (notification.isFetchingError()) { networkRequestStatusText.onNext("Error occured"); } else { networkRequestStatusText.onNext(""); } })); compositeSubscription.add( repositorySearchSource .filter(DataStreamNotification::isOnNext) .map(DataStreamNotification::getValue) .flatMap((repositorySearch) -> { Log.d(TAG, "Found " + repositorySearch.getItems().size() + " repositories with search " + repositorySearch.getSearch()); final List<Observable<GitHubRepository>> observables = new ArrayList<>(); for (int repositoryId : repositorySearch.getItems()) { Log.v(TAG, "Process repositoryId: " + repositoryId); final Observable<GitHubRepository> observable = getGitHubRepository.call(repositoryId) .doOnNext((repository) -> Log.v(TAG, "Received repository " + repository.getId())); observables.add(observable); if (observables.size() >= MAX_REPOSITORIES_DISPLAYED) { break; } } return Observable.combineLatest( observables, (args) -> { Log.v(TAG, "Combine items into a list"); final List<GitHubRepository> list = new ArrayList<>(); for (Object repository : args) { list.add((GitHubRepository) repository); } return list; } ); }) .subscribe((repositories) -> { Log.d(TAG, "Publishing " + repositories.size() + " repositories from the ViewModel"); RepositoriesViewModel.this.repositories.onNext(repositories); })); compositeSubscription.add(repositorySearchSource.connect()); }