This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; On my journey into event sourcing in clojure I'm trying different approaches | |
;; of modeling events and event handling in clojure. | |
;; A little ceremony to pay homage to the gods of clojure: | |
(ns handler-protocol | |
(:use clojure.contrib.trace) | |
(:use clojure.pprint) | |
(:use clojure.test)) | |
;; My example problem domain for this will be a very simple sketch of twitter. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns state-is-a-fold | |
(:use clojure.test)) | |
;;; After all, state is a fold of events. For example let's say the events are a sequence of numbers | |
;;; and we are folding by addition: | |
(deftest simple | |
(let [events [1 5 2 4 3] | |
state (reduce + events)] | |
(is (= 15 state)))) |