<commit_before>(ns om-next-e2e.ui
  (:require [goog.dom :as gdom]
            [om.next :as om :refer-macros [defui]]
            [om.dom :as dom]))

(enable-console-print!)

(println "Hello world!")

(defui HelloWorld
  Object
  (render [this]
    (dom/div nil "Hello, World!")))

(def hello (om/factory HelloWorld))

(js/ReactDOM.render (hello) (gdom/getElement "main-app-area"))
<commit_msg>initial implementation of frontend counter<commit_after>(ns om-next-e2e.ui
  (:require [goog.dom :as gdom]
            [om.next :as om :refer-macros [defui]]
            [om.dom :as dom]))

(defonce app-state (atom {:counter 0}))

(defmulti read om/dispatch)
(defmulti mutate om/dispatch)

(defn get-state-key [{:keys [state]} key]
  (let [st @state]
    (if-let [[_ value] (find st key)]
      {:value value}
      :not-found)))

(defmethod read :default [env key params]
  (get-state-key env key))

(defmethod mutate 'ui/increment [{:keys [state]} _ {:keys [value]}]
  {:value {:keys [:counter]}
   :action (fn [] (swap! state
                         #(update % :counter (fn [old] (+ old value)))))})

(def reconciler
  (om/reconciler
    {:state app-state :parser (om/parser {:read read :mutate mutate})}))

(defn mutate! [query]
  (om/transact! reconciler query))

(enable-console-print!)

(defui Counter
  static om/IQuery
  (query [this] [:counter])
  Object
  (render [this]
          (dom/div nil
                   (dom/div nil (str "Counter: " (:counter (om/props this))))
                   (dom/button #js {:onClick
                                    #(mutate!
                                       `[(ui/increment {:value 1}) :counter])}
                               "Increment"))))

(om/add-root! reconciler
  Counter (gdom/getElement "main-app-area"))

{'fraction_non_alphanumeric': 0.1643059490084986, 'fraction_numerical': 0.0022662889518413596, 'mean_word_length': 2.4357976653696496, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7285051', 'n_tokens_mistral': 617, 'n_tokens_neox': 598, 'n_words': 160}