Fork me on GitHub

Is there something I can plug in that'll let me inspect app-db on the SPA?


(ns ^:figwheel-always x.core (:require [re-com.core :refer [v-box label title p gap]] [re-com.util :refer [get-element-by-id]] [reagent.core :as reagent])) (defn main [] [gap :size "1em"]) (defn ^:export mount-ui [] (reagent/render [main] (get-element-by-id "app"))) (mount-ui) ---- I get this exception when I try to run that code: Uncaught TypeError: Cannot read property 'call' of undefined. Any ideas what can cause it? If I use [p "text here"] it works, and any normal functions that I define ala reagent works


@mbertheau: do you mean something more than inspecting @re-frame.db/app-db in the repl ?


When you are waiting for an AJAX request, how do you show the user that progress is happening?


@pupeno: i use a flag in app-state and show a loading component when it's true


loading view component*


quantisan: what about forms? the form is submitted and I’m waiting for the reply that might me OK or validation errors.


you can add a modal, alert box, etc. on your form to show it's loading


this seem like a design choice


It’s part design, part coding. I’m also interested in how to keep track of waiting for something without having to do it explicitly every time. Some useful pattern.


i've also done dispatch for redirect or whatever inside the submit dispatch


event driven


Wow… I just prototyped a solution for forms and it took 3 lines of code:


re-frame + reagent is awesome!


@mbertheau: Here is a useful debugging tip I picked up from @escherize ... When you are debugging a reagent view ... and particularly the value coming through in a cursor or subscription (re-frame) or props ... ... add something like this to the hiccup in your view ... [:pre (with-out-str (pprint @some-ratom))] ;; assuming that @some-ratom is the value you want to observe You don't even have to use pprint, you could just do this: [:pre (pr-str @some-ratom)] If you do use the pprint version then you'll need to require it in at the top of your view.cljs: [cljs.pprint :refer [pprint]] Further note: the advanced version of this technique is to not use pr-str or pprint but instead to use @yogthos' excellent json-html library: for an even more carefully arranged display.


I've added something to that


I'm not sure if it's a great idea, but I add the json-html'd table to the bottom of the top level form, in a div with a class that has display:none.


I hacn't noticed any performance issues with it so far.


btw, @mikethompson I've been using recom (and learning flexbox) more lately, it's by far the better way to build html.


@escherize: excellent. I actually think that the layout side of re-com is probably the most useful and reusable part of the whole thing


flexbox is still pretty terrible (compared to other non-browser technologies I've used) BUT it is still waaaaaaay better than the rest of the HTML layout tech available


@escherize: just to state the obvious ... be really sure to read the docs supplied:


There's some hard-fought-for knowledge in those docs. A lot of the flexbox tutorials drown you in detail. But the key thing to understand when nesting them, is the flex attribute (aka :size in re-com). It always resolves to a triple of values (GSB).


You probably know that already, but I always like to stress it.


BTW, we have been working on a "grid" component for re-com. Virtual vertical scrolling (ie. can handle 100K rows). Row headers, Col headers. Scrollbars etc


@mikethompson: do you think it's still too early to use flexbox for modern web apps development?


because I just discovered re-com and it's beautiful


ivanbokii: flexbox has pretty good support across the board now for, as you say, modern development


@gjnoonan: yep, checked that, but a bit afraid about firefox problems listed here


What is going on here? "Reactive deref not supported in lazy seq"


What it says on the tin


You need to force the seq


With something like doall


yeah, I need to look up lazy sequence and understand better, I'm new to clojure (relatively)


IIRC reagent tracks invalidation with reading a mutable var referring to the currently rendered component; I imagine if you put a deref in a lazy seq then the component might end up being different than what you expect and it will break


how do I lookup a db value without having it change?


Basically any sequence in Clojure is lazy (unless something explicitly says in docs it's eager)


ok, thanks, I'll do more learning and figure that part out


Things like map, filter and so on return lazy sequences by default (there was one frequently usedseq function that is eager, but I'm not 100% sure which one so I don't want to confuse)


BTW, nevermind that request, I thought that because I wasn't seeing a value that I'd "missed" the signal from the mutation. It seems that a subscription always fires the first time.


I was failing to de-ref a value from a reaction as I moved from statically defined data to data from a subscription.


I'm building the first page into an SPA replacement of an existing J2EE, jquery/Struts/Hibernate + Backbone + handwritten JS/Java knitted castle...


@ivanbokii: regarding using flexbox now, or not, I wrote this in the the re-com README > the grinding pain and longevity of IE6 has conditioned many to expect 8, 9 and 10 to hang around forever too. But, this time around, there's quite a different dynamic. Microsoft itself is very actively forcing their demise - come Jan 12th 2016 corporates will have to be on IE11. See > So, by Q1 2016, the market share of IE9 and IE10 will have diminished sufficiently that they could be ignored. Probably. Maybe. If so, a modern flexbox implementation will be available on all the browsers you then care about. So that's surprisingly soon, but not now!


I'm in the fortunate position that I don't have to worry about the retail web. My target is Chrome.