<commit_before>import React from 'react'
import TanokMixin from '../../mixin.js';
import {actionIs, filter, debounce} from '../../helpers.js';

/*
  MODEL
*/
export function init() {
  return {
    count: 0,
    history: []
  }
};

/*
  UPDATE
*/
export let update = [
  [[actionIs('inc')], (params, state) => {
    state.count += 1
    return [state, wowEffect]
  }],
  [[actionIs('dec')], (params, state) => {
    state.count -= 1
    return [state]
  }],
  [[actionIs('wow'), debounce(1000)], (params, state) => {
    state.history.push(state.count)
    return [state]
  }]
]

function wowEffect (state, es) {
  return Rx.Observable.just(1).do(function(){
    es.send('wow')
  })
}

/*
  VIEW
*/
export const Counter = React.createClass({
  mixins: [TanokMixin],

  onPlusClick: function() {
    this.send('inc')
  },
  onMinusClick: function() {
    this.send('dec')
  },
  render: function() {
        return <div>
        <button onClick={this.onPlusClick}>+</button>
        <span>{this.props.count}</span>
        <button onClick={this.onMinusClick}>-</button><commit_msg>More consistant counter example<commit_after>import React from 'react'
import TanokMixin from '../../mixin.js';
import {actionIs, filter, debounce} from '../../helpers.js';

/*
  MODEL
*/
export function init() {
  return {
    count: 0,
    history: []
  }
};

/*
  UPDATE
*/
export let update = [
  [[actionIs('inc')], (params, state) => {
    state.count += 1
    return [state, wowEffect]
  }],
  [[actionIs('dec')], (params, state) => {
    state.count -= 1
    return [state, wowEffect]
  }],
  [[actionIs('wow'), debounce(1000)], (params, state) => {
    state.history.push(state.count)
    return [state]
  }]
]

function wowEffect (state, es) {
  return Rx.Observable.just(1).do(function(){
    es.send('wow')
  })
}

/*
  VIEW
*/
export const Counter = React.createClass({
  mixins: [TanokMixin],

  onPlusClick: function() {
    this.send('inc')
  },
  onMinusClick: function() {
    this.send('dec')
  },
  render: function() {
        return <div>
        <button onClick={this.onPlusClick}>+</button>
        <span>{this.props.count}</span>
        <button onClick={this.onMinusClick}>-</button>
{'fraction_non_alphanumeric': 0.19506624029237093, 'fraction_numerical': 0.007309273640931932, 'mean_word_length': 3.018348623853211, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, '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': '2452983', 'n_tokens_mistral': 796, 'n_tokens_neox': 764, 'n_words': 157}