<commit_before>package com.kickstarter.libs;

import android.os.Bundle;

import rx.subjects.PublishSubject;

public class Presenter<ViewType> {
  protected final PublishSubject<ViewType> viewSubject = PublishSubject.create();

  protected void onCreate(Bundle savedInstanceState) {
    viewSubject.onNext(null);
  }

  protected void onResume(ViewType view) {
    viewSubject.onNext(view);
  }

  protected void onPause() {
    viewSubject.onNext(null);
  }

  protected void onDestroy() {
    viewSubject.onCompleted();
  }

  public void save(Bundle state) {
    // TODO
  }

}
<commit_msg>Add subscriptions, unsubscribe to all when presenter is destroyed<commit_after>package com.kickstarter.libs;

import android.os.Bundle;

import java.util.ArrayList;
import java.util.List;

import rx.Subscription;
import rx.subjects.PublishSubject;

public class Presenter<ViewType> {
  protected final PublishSubject<ViewType> viewSubject = PublishSubject.create();
  protected final List<Subscription> subscriptions = new ArrayList<>();

  protected void onCreate(Bundle savedInstanceState) {
    viewSubject.onNext(null);
  }

  protected void onResume(ViewType view) {
    viewSubject.onNext(view);
  }

  protected void onPause() {
    viewSubject.onNext(null);
  }

  protected void onDestroy() {
    for (Subscription subscription : subscriptions) {
      subscription.unsubscribe();
    }

    viewSubject.onCompleted();
  }

  public void save(Bundle state) {
    // TODO
  }
}

{'fraction_non_alphanumeric': 0.10013531799729364, 'fraction_numerical': 0.0, 'mean_word_length': 4.226148409893993, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1081882', 'n_tokens_mistral': 447, 'n_tokens_neox': 433, 'n_words': 99}