How to get devCards to work with re-frame?

Devcards aims to provide a visual REPL experience for ClojureScript. They offer support for Reagent and OM . How can I get devCards to work with re-frame ?

+5
source share
2 answers

This is a recurring issue with repeat frames and patterns. The main problem is the global variables in re-frame (the main problem is db, but handlers and subscriptions can also be a problem), which do not reproduce well with the idea of ​​rendering multiple templates on the same page.

One potential solution is to display each devcard inside an iframe. Each devcard will be isolated from each other, although they are contained and visually displayed on one page. This is probably not the most efficient solution, but it works: I implemented it in my Cartesian widget in the iframe section . It has a couple of examples using re-crop

Although published in clojars as [org.clojars.nberger/devcards "0.2.3-0-iframe"] , it needs some work to provide a more friendly way to create iframe templates and possibly devcard macros intended to crop again. There may also be some edges of the polishing UI. But feel free to use it. Of course, contributions and feedback are welcome.

I will give an example here to show how to use it:

 (defcard-rg re-frame-component-initialize-db "This is the same re-frame component, but now using data-atom to initialize the db, rendered in an iframe:" (fn [data-atom _] (setup-example-1) (re-frame/dispatch [:initialize-db @data-atom]) [re-frame-component-example]) {:guest-name "John"} {:iframe true}) 

(the example is based on re-frame 0.7.x, but everything should work the same with newer versions, because the iframe mechanism is indifferent to using re-frame or something else)

+4
source

They say you can not front page :

re-frame remains incomplete, and it lags behind a couple of paths - for example, it does not work as well as we would like with devcards

+1
source

Source: https://habr.com/ru/post/1271994/


All Articles