Created
January 19, 2014 23:53
-
-
Save geraldodev/8512669 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(defn concat-korks | |
[korks k2orks] | |
(if-not (sequential? korks) | |
(if-not (sequential? k2orks) | |
[korks k2orks] | |
(if (list? k2orks) | |
(conj k2orks korks) | |
(into [korks] k2orks))) | |
(if (list? korks) | |
(if-not (sequential? k2orks) | |
(into (list k2orks) korks) | |
(if (list? k2orks) | |
(into k2orks korks) | |
(into (seq k2orks) korks))) | |
(if-not (sequential? k2orks) | |
(conj korks k2orks) | |
(into korks k2orks))))) | |
;Test:) | |
(defn test-concat-korks | |
[] | |
(is (= [:one :two] (concat-korks :one :two))) | |
(is (= [:one :two] (concat-korks [:one] [:two]))) | |
(is (= [:one :two] (concat-korks [:one] '(:two)))) | |
(is (= [:one :two] (concat-korks [:one] :two))) | |
(is (= [:one :two] (concat-korks :one [:two]))) | |
(is (= '(:one :two) (concat-korks :one '(:two)))) | |
(is (= '(:one :two) (concat-korks '(:one) :two))) | |
(is (= '(:one :two) (concat-korks '(:one) '(:two)))) | |
(is (= '(:one :two) (concat-korks '(:one) [:two])))) | |
(defn get-state | |
"Takes a pure owning component and sequential list of keys and | |
returns a property in the component local state if it exists. Will | |
never return pending state values." | |
([owner] (aget (.-state owner) "__om_state")) | |
([owner korks] | |
(cond | |
(not (sequential? korks)) | |
(get (aget (.-state owner) "__om_state") korks) | |
(empty? korks) | |
(get-state owner) | |
:else | |
(get-in (aget (.-state owner) "__om_state") korks))) | |
([owner korks k2orks] | |
(get-state owner (concat-korks korks k2orks)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment