This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-24
Channels
- # beginners (12)
- # cider (3)
- # clara (3)
- # cljs-dev (3)
- # cljsrn (19)
- # clojure (83)
- # clojure-android (1)
- # clojure-dev (15)
- # clojure-dusseldorf (1)
- # clojure-greece (30)
- # clojure-italy (10)
- # clojure-madison (1)
- # clojure-nl (6)
- # clojure-russia (274)
- # clojure-spec (51)
- # clojure-uk (31)
- # clojurescript (38)
- # core-async (7)
- # cursive (11)
- # datascript (1)
- # datomic (63)
- # emacs (10)
- # figwheel (1)
- # hoplon (27)
- # jobs (11)
- # klipse (4)
- # lein-figwheel (1)
- # lumo (6)
- # nyc (1)
- # off-topic (278)
- # om (12)
- # pedestal (10)
- # protorepl (31)
- # re-frame (13)
- # reagent (23)
- # remote-jobs (1)
- # spacemacs (9)
- # untangled (24)
- # yada (54)
` (:require [ajax.core :refer [GET POST ajax-request detect-response-format text-request-format text-response-format]]) (:import [http://goog.net XhrIo]) (defn response-handler [[ok xhrio]] (if ok (let [response (.getResponse xhrio) headers (.getAllResponseHeaders xhrio)] (re-frame/dispatch [:response-convert {:response response :headers headers}])) (let [error-response (.getResponse (:response xhrio)) headers (.getAllResponseHeaders (:response xhrio))] (re-frame/dispatch [:response-convert {:response error-response :headers headers}])))) (def request {some-request-map}) (ajax-request {:uri "/enpoint" :method (:method request) :headers (:headers request) :params (:body request) :format (text-request-format) :response-format {:read identity :description "raw"} :handler repsonse-handler})`
but your server also need to expose the headers, so in the handler for /endpoint it needs to add to response:
(assoc-in response [:headers "Access-Control-Expose-Headers"] "Access-Control-Allow-Headers,Access-Control-Allow-Methods,Access-Control-Allow-Origin,Content-Length,Date,Server")
[clj-http.client :as http] response (http/post "/endpoint" {:headers (:headers request) :body (:body request)}) (select-keys response [:headers :body])
How can I merge multiple dbs?
But when I start the app, I initialize the database with re-frame dispatch. When I add a component with its own db to the app and initialize that db at loading, do I have to merge the db in the init event?
in "`re-frame` way of life", you dont have local state. Somewhere in tutorial has a section about "single source of true"
souenzzo: not that straightforward
` (:require [ajax.core :refer [GET POST ajax-request detect-response-format text-request-format text-response-format]]) (:import [http://goog.net XhrIo]) (defn response-handler [[ok xhrio]] (if ok (let [response (.getResponse xhrio) headers (.getAllResponseHeaders xhrio)] (re-frame/dispatch [:response-convert {:response response :headers headers}])) (let [error-response (.getResponse (:response xhrio)) headers (.getAllResponseHeaders (:response xhrio))] (re-frame/dispatch [:response-convert {:response error-response :headers headers}])))) (def request {some-request-map}) (ajax-request {:uri "/enpoint" :method (:method request) :headers (:headers request) :params (:body request) :format (text-request-format) :response-format {:read identity :description "raw"} :handler repsonse-handler})`
in that case I think clj-http exposes headers on the response, so maybe try:
Anyone have any suggestions or insights into getting react-virtualized to work in a re-frame application? I think we're having low level dependency conflicts with react itself being included by reagent and other libraries. We're working through that to see, but I am hoping someone has had success before. Thanks.
But when I start the app, I initialize the database with re-frame dispatch. When I add a component with its own db to the app and initialize that db at loading, do I have to merge the db in the init event?