Questions tagged [re-frame]

re-frame is a pattern for writing SPAs in ClojureScript, using Reagent.

To build a re-frame app, you:

  • design your app's data structure (data layer)
  • write and register subscription functions (query layer)
  • write Reagent component functions (view layer)
  • write and register event handler functions (control layer and/or state transition layer)

Features:

  1. The functions you write are pure, so the computational pieces of your app can be described, understood and tested independently. You won't need sophisticated Dependency Injection to test. So much incidental complexity evaporates.
  2. These computational parts are composed via reactive data flows - a dynamic, unidirectional Signal graph.
  3. The resulting architecture involves "derived data" flowing in a two-stage, reactive loop. Without realising it, you will be explicitly modelling time.
  4. It is fast, straight out of the box. You won't have to go through this sort of pain.
  5. The surprising thing about re-frame is how simple it is. Beautifully simple! Our reference implementation is little more than 200 lines of (ClojureScript) code. Learn it in an afternoon.
  6. But it scales up nicely to more complex apps. Frameworks are just pesky overhead at small scale - measure them instead by how they help you tame the complexity of bigger apps.
  7. Re-frame is impressively buzzword compliant: it has FRP-nature, unidirectional data flow, pristinely pure functions, conveyor belts, statechart-friendliness (FSM) and claims an immaculate hammock conception. It also has a charming xkcd reference (soon) and a hilarious, insiders-joke T-shirt, ideal for conferences (in design).

Github

144 questions
0
votes
1 answer

How to dispatch events in re-frame framework (clojurescript) in the REPL?

I am using figwheel,I want to dispatch events manually from REPL. e.g after my app is connected to REPL (in-ns 'my-re-frame.core) (re-frame/dispatch-sync [::events/initialize-db]) I get following error "RuntimeException Invalid token:…
anish
  • 1,035
  • 4
  • 13
  • 27
0
votes
1 answer

re-frame: adding a new map element in nested vector

I have this structure (ordered map) in my "db" with the keyword ":questions": {:33 {:question "one", :id 33, :answers [{:id 22, :question_id 33, :answer "one", :correct false} {:id 4, :question_id 33,…
aarkerio
  • 2,183
  • 2
  • 20
  • 34
0
votes
1 answer

"Warning: The Main-Class specified does not exist within the jar." in combined Clojure + Clojurescript re-frame project

I have developed over 30 Clojure projects, but this is my first foray into Clojurescript. I built a SPA using re-frame and now I am attempting to create the uberjar for it. When I run lein uberjar, I get the following error message: Warning: The…
frank
  • 501
  • 8
  • 21
0
votes
2 answers

No view is being rendered in re-frame app

Here's a simple re-frame app that I tried to create based on the existing example project in re-frame's github repo. But it is only displaying things from the html file. Seems like no event is being dispatched. Can anyone point out what am I doing…
halfo
  • 223
  • 2
  • 11
0
votes
1 answer

Idiomatic way of handling dynamic classes in Reagent or Re-Frame application

In JavaScript, a common way to handle dynamic classes is to use classnames library. I couldn't find any alternative solutions for ClojureScript, and it seems most people are fine with using inline if statements with (str ...) like: (str "location…
Yury Solovyov
  • 526
  • 8
  • 18
0
votes
1 answer

Parse JSON body from HTTP request (with ring and re-frame-http-fx)

I have a re-frame-based UI and try to communicate with my server using re-frame-http-fx. Sending and responding seems to work. However, I can't figure out how to parse the JSON body into a Clojure map on the server. Here is my handler.clj as minimal…
notan3xit
  • 2,386
  • 2
  • 21
  • 26
0
votes
1 answer

Connecting re-frame app to a Database

I'm having a problem with my re-frame application. I can't figure out how to connect it to a local database on my machine. In other applications I've written, I've had to add the database specifications (username, password etc) into profiles.clj.…
rbb
  • 989
  • 6
  • 19
0
votes
1 answer

What does the % character mean in the re-frame todomvc app todo-item function?

The re-frame todomvc views namespace contains a function todo-item which contains the following snippet: (when @editing [todo-edit {:class "edit" :title title :on-save #(dispatch [:save id %]) …
nilo de roock
  • 4,077
  • 4
  • 34
  • 62
0
votes
1 answer

How to push changes to a Reagent component with Re-frame subscriptions and handlers?

Consider the following hypothetical, simplified clojurescript snippets: (def cat (r/atom [{:id 0 :data {:text "ROOT" :test 17} :prev nil :par nil} {:id 1 :data {:text "Objects" :test 27} :prev nil :par 0} {:id 2…
nilo de roock
  • 4,077
  • 4
  • 34
  • 62
1 2 3
9
10