Fork me on GitHub
#re-frame
<
2019-08-17
>
Lu10:08:34

Devcards are compatible with re-frame https://juxt.pro/blog/posts/cljs-apps.html

johanatan18:08:09

are there any adjustments that need to be made or do you just use both re-frame and devcards as normal?

Lu18:08:37

I found myself using the approach mentioned in issue #105, but only when I needed to walk the state history ... another trick I used was to wrap views with functions that would simply provide all the data to be consumed by the component.. in this way you can either hard code the data for the devcard purpose or get it via a subscription in your actual app..

johanatan18:08:46

do you know what the guy was trying to achieve with the iframe devcard branch or why that was necessary?

Lu18:08:33

Yeah basically if you have one global state for all your cards, the history will change for all of them anytime one devcard updates because they share the same ratom.. I personally don’t find extremely useful the ability to walk the state history .. I rather have the state steps hardcoded in different cards so that I can look at them all at once without the need to interact with the UI

johanatan04:08:31

Ah, gotcha. Yea, that does sound like a nice way to work. At the same time, for complex interactions, it could explode the number of cards required.

dominicm20:08:33

I spoke to someone who said that they have pure and subscribing variations of their components. Similar to Abramov's containers and presenters pattern (I think that's what it is called)

👍 4
bartuka23:08:10

I'm trying to use cljs-ajax to perform a request from my re-frame event to my localhost web server. However, it seems like the uri parameter cannot specify a port. only the endpoint.

(POST
    ""
    {:format :json
     :params {:value (:value db)}
     :handler #(re-frame/dispatch [::update-database %])
     :error-handler #(re-frame/dispatch [::error-handler %])})
this example returns status 0. Seems like my endpoint cannot be reach. If I change the uri to /save it calls some html page. I think I have to make a previous setup to let the library knows the whole url address of my backend service. But I could not find where I specify that

bartuka23:08:43

{:uri , :last-method POST, :last-error [0], :last-error-code 6, :debug-message Http response at 400 or 500 level, :status 0, :status-text Request failed., :failure :failed} the whole error message

Lu23:08:17

(ajax/ajax-request
 {:uri ""
  :method :get
  :handler #(handler %)
  :response-format (ajax/transit-response-format)})

Lu23:08:20

This works for me

Lu23:08:05

I'll try with a post

dpsutton23:08:24

(ajax/POST "" )
#object[Object [object Object]]
;;; from python -m SimpleHTTPServer 8000
Serving HTTP on 0.0.0.0 port 8000 ...
127.0.0.1 - - [17/Aug/2019 18:37:31] code 501, message Unsupported method ('OPTIONS')
127.0.0.1 - - [17/Aug/2019 18:37:31] "OPTIONS / HTTP/1.1" 501 -

Lu23:08:01

(POST ""
      {:params {:email "this-is-email@d"}
       :handler #(rf/dispatch [:foo %])
       :format :transit})
Again.. working on my machine..