0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-09 08:20:45 -05:00

Add initial approach for client-server communication.

This commit is contained in:
Andrey Antukh 2016-02-24 17:24:11 +02:00
parent 41dac4bc7d
commit 7aaf894a98

45
src/uxbox/repo.cljs Normal file
View file

@ -0,0 +1,45 @@
(ns uxbox.repo
"A main interface for access to remote resources."
(:refer-clojure :exclude [do])
(:require [postal.client :as ps]
[beicon.core :as rx]))
(def ^:private ^:const +client+
"https://test.uxbox.io")
(defn novelty
[type data]
(rx/from-promise
(ps/novelty +client+ type data)))
(defn query
([type]
(rx/from-promise
(ps/query +client+ type)))
([type data]
(rx/from-promise
(ps/query +client+ type data))))
(defmulti -do
(fn [type data] type))
(defn do
"Perform a side effectfull action accesing
remote remote resources."
([type]
(-do type nil))
([type data]
(-do type data)))
;; (defmethod do :login
;; [type data]
;; (rx/from-promise
;; (ps/novelty :login data)))
(defmethod -do :login
[type data]
(->> (rx/of {:fullname "Cirilla Fiona"
:photo "/images/favicon.png"
:username "cirilla"
:email "cirilla@uxbox.io"})
(rx/delay 100)))