<commit_before>package redux.counter

import org.w3c.dom.events.Event
import redux.Reducer
import redux.Store
import redux.counter.Action.DECREMENT
import redux.counter.Action.INCREMENT
import kotlin.browser.document

enum class Action {
    INCREMENT, DECREMENT
}

fun main(args: Array<String>) {
    val reducer = Reducer { state: Int, action: Any ->
        when (action) {
            INCREMENT -> state + 1
            DECREMENT -> state - 1
            else -> state
        }
    }

    val store = Store.create(reducer, 0)
    val valueEl = document.getElementById("value")

    val render = {
        valueEl?.innerHTML = "${store.getState()}"
    }

    render()
    store.subscribe(render)

    document.getElementById("increment")
            ?.addEventListener("click", { event: Event ->
                store.dispatch(INCREMENT)
            })

    document.getElementById("decrement")
            ?.addEventListener("click", {
                store.dispatch(DECREMENT)
            })

    document.getElementById("incrementIfOdd")
            ?.addEventListener("click", { event: Event ->
                if (store.getState() % 2 == 0) {
                    store.dispatch(INCREMENT)
                }
            })

    document.getElementById("incrementAsync")
            ?.addEventListener("click", { event: Event ->
                kotlin.browser.window.setTimeout({
                    store.dispatch(INCREMENT)
                }, 1000)
            })
}<commit_msg>Fix increment if odd logic.<commit_after>package redux.counter

import org.w3c.dom.events.Event
import redux.Reducer
import redux.Store
import redux.counter.Action.DECREMENT
import redux.counter.Action.INCREMENT
import kotlin.browser.document

enum class Action {
    INCREMENT, DECREMENT
}

fun main(args: Array<String>) {
    val reducer = Reducer { state: Int, action: Any ->
        when (action) {
            INCREMENT -> state + 1
            DECREMENT -> state - 1
            else -> state
        }
    }

    val store = Store.create(reducer, 0)
    val valueEl = document.getElementById("value")

    val render = {
        valueEl?.innerHTML = "${store.getState()}"
    }

    render()
    store.subscribe(render)

    document.getElementById("increment")
            ?.addEventListener("click", { event: Event ->
                store.dispatch(INCREMENT)
            })

    document.getElementById("decrement")
            ?.addEventListener("click", {
                store.dispatch(DECREMENT)
            })

    document.getElementById("incrementIfOdd")
            ?.addEventListener("click", { event: Event ->
                if (store.getState() % 2 != 0) {
                    store.dispatch(INCREMENT)
                }
            })

    document.getElementById("incrementAsync")
            ?.addEventListener("click", { event: Event ->
                kotlin.browser.window.setTimeout({
                    store.dispatch(INCREMENT)
                }, 1000)
            })
}
{'fraction_non_alphanumeric': 0.11613119143239625, 'fraction_numerical': 0.006693440428380187, 'mean_word_length': 1.9132553606237817, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '6715680', 'n_tokens_mistral': 845, 'n_tokens_neox': 781, 'n_words': 156}