From 7aaf894a98d7ebd53ca334920a65cc1bc9740c8b Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 24 Feb 2016 17:24:11 +0200 Subject: [PATCH] Add initial approach for client-server communication. --- src/uxbox/repo.cljs | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/uxbox/repo.cljs diff --git a/src/uxbox/repo.cljs b/src/uxbox/repo.cljs new file mode 100644 index 0000000000..0014ce44b2 --- /dev/null +++ b/src/uxbox/repo.cljs @@ -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)))