Use deftype for user data events.

This commit is contained in:
Andrey Antukh 2017-01-16 17:49:29 +01:00
parent e3f58f6823
commit 92fc9c1ca6
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95

View file

@ -20,7 +20,7 @@
;; --- Profile Fetched ;; --- Profile Fetched
(defrecord ProfileFetched [data] (deftype ProfileFetched [data]
ptk/UpdateEvent ptk/UpdateEvent
(update [this state] (update [this state]
(assoc state :profile data))) (assoc state :profile data)))
@ -31,7 +31,7 @@
;; --- Fetch Profile ;; --- Fetch Profile
(defrecord FetchProfile [] (deftype FetchProfile []
ptk/WatchEvent ptk/WatchEvent
(watch [_ state s] (watch [_ state s]
(->> (rp/req :fetch/profile) (->> (rp/req :fetch/profile)
@ -44,7 +44,7 @@
;; --- Profile Updated ;; --- Profile Updated
(defrecord ProfileUpdated [data] (deftype ProfileUpdated [data]
ptk/WatchEvent ptk/WatchEvent
(watch [_ state s] (watch [_ state s]
(rx/of (profile-fetched data) (rx/of (profile-fetched data)
@ -56,7 +56,7 @@
;; --- Update Profile ;; --- Update Profile
(defrecord UpdateProfile [data on-success on-error] (deftype UpdateProfile [data on-success on-error]
ptk/WatchEvent ptk/WatchEvent
(watch [_ state s] (watch [_ state s]
(letfn [(handle-error [{payload :payload}] (letfn [(handle-error [{payload :payload}]
@ -80,7 +80,7 @@
;; --- Password Updated ;; --- Password Updated
(defrecord PasswordUpdated [] (deftype PasswordUpdated []
ptk/WatchEvent ptk/WatchEvent
(watch [_ state stream] (watch [_ state stream]
(rx/of (uum/info (tr "settings.password-saved"))))) (rx/of (uum/info (tr "settings.password-saved")))))
@ -91,7 +91,7 @@
;; --- Update Password (Form) ;; --- Update Password (Form)
(defrecord UpdatePassword [data] (deftype UpdatePassword [data]
ptk/WatchEvent ptk/WatchEvent
(watch [_ state s] (watch [_ state s]
(let [params {:old-password (:old-password data) (let [params {:old-password (:old-password data)
@ -113,7 +113,7 @@
;; --- Update Photo ;; --- Update Photo
(defrecord UpdatePhoto [file done] (deftype UpdatePhoto [file done]
ptk/WatchEvent ptk/WatchEvent
(watch [_ state stream] (watch [_ state stream]
(->> (rp/req :update/profile-photo {:file file}) (->> (rp/req :update/profile-photo {:file file})