<commit_before>import {Component, OnInit, ChangeDetectorRef, ChangeDetectionStrategy} from '@angular/core';
import {NavController, Toast, } from 'ionic-angular';

import { IncrementService } from './increment.service';


@Component({
  // templateUrl: 'build/pages/home/home.html'
  template: require('./increment.html'),
  providers: [IncrementService],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class IncrementPage implements OnInit {
  constructor(
    private nav: NavController,
    private cd: ChangeDetectorRef,
    private service: IncrementService
  ) { }

  ngOnInit() { }

  ionViewLoaded() {
    this.showToast('middle'); // ngOnInitに書くとテスト時にエラーになる。
  }


  showToast(position: string) {
    let toast = Toast.create({
      message: 'push "+" button to increment counter.',
      duration: 3000,
      position: position
    });
    this.nav.present(toast);
  }


  increment() { this.service.increment(); }

  decrement() { this.service.decrement(); }


  get userName() { return this.service.userName$; }

  get counter() { return this.service.counter$; }
}<commit_msg>Fixed: increment.ts<commit_after>import {Component, OnInit, ChangeDetectorRef, ChangeDetectionStrategy} from '@angular/core';
import {NavController, Toast, } from 'ionic-angular';

import { IncrementService } from './increment.service';


@Component({
  // templateUrl: 'build/pages/home/home.html'
  template: require('./increment.html'),
  providers: [IncrementService],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class IncrementPage implements OnInit {
  constructor(
    private nav: NavController,
    private cd: ChangeDetectorRef,
    private service: IncrementService
  ) { }

  ngOnInit() { }

  ionViewLoaded() {
    this.showToast('middle'); // ngOnInitに書くとテスト時にエラーになる。
  }


  showToast(position: string) {
    let toast = Toast.create({
      message: 'push "+" button to increment counter.',
      duration: 3000,
      position: position
    });
    this.nav.present(toast);
  }


  increment() { this.service.increment(); }

  decrement() { this.service.decrement(); }


  get userName() { return this.service.userName$; }


  // templateのasyncパイプへObservableを渡しているが、
  // 自前でsubscribeしてtemplateに直接値を渡した方がレスポンスは速い。
  // (asyncパイプはdirty checkingのようなものなので)
  get counter() { return this.service.counter$; }
}
{'fraction_non_alphanumeric': 0.13162393162393163, 'fraction_numerical': 0.003418803418803419, 'mean_word_length': 4.1002178649237475, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1341818', 'n_tokens_mistral': 775, 'n_tokens_neox': 734, 'n_words': 149}