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
3
votes
2 answers

How to implement undo and redo in a crud type of application when using reagent and re-frame?

Although on the re-frame home page it says that "Save and Undo become quite easy.", the re-frame example app 'todomvc' has no code which implements an undo / redo feature. When using an OO language like Java it is common practice to implement undo /…
nilo de roock
  • 4,077
  • 4
  • 34
  • 62
3
votes
1 answer

How to update same input field by typing and from code in reagent/re-frame?

I have a reagent component with an integer input field and two buttons "+1" and "-1". I'd like to make it possible for the user to: enter an integer value directly in the input field click on "+1" to increment the value in the input field by…
pbkhrv
  • 647
  • 4
  • 11
3
votes
1 answer

The data-source property isn't propagated from reagent to the render method of the React Native ListView component

I'm trying to render a React Native ListView in reagent. I have the following snippet: (def data-source (React.ListView.DataSource. #js{:rowHasChanged (fn [a b] false)})) (defn render-row [] [ui/view]) (def rows (clj->js ["whoa",…
eploko
  • 5,347
  • 2
  • 28
  • 23
3
votes
2 answers

How to have handlers run sequentially in re-frame?

Starting with these two handlers that take care of getting the current user information: (re-frame/register-handler :got-user (fn [db [_ user]] (assoc db :user user))) (re-frame/register-handler :get-user (fn [db [_]] (ajax/GET…
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
2
votes
1 answer

Clojurescript Re-frame site with quill editor integration

I am new in JS and clojurescript. I need for a project based on clojurescript re-frame to add an editor WYSIWYG. I did try to add Quill following the Quickstart. From my index.html file I put as advised the:
gwenael
  • 35
  • 5
2
votes
1 answer

Why is :style on re-frame sometimes used with brackets, with curly brackets, and without anything?

I have been using Clojure, ClojureScript, lein, shadow-cljs, Emacs, and CIDER to work on a Clojure/ClojureScript dynamic web app project. Usually, I build the project by executing the command cider-jack-in-cljs in Emacs, choosing shadow-cljs, then…
Pedro Delfino
  • 2,421
  • 1
  • 15
  • 30
2
votes
1 answer

What is the quickest and dirtiest way to store a ratom on a server?

Periodically, on my super simple web app, I will want to reset my app state (which is in a reagent atom) back to a pristine default. Before I do, however, I want to send my sullied app state off to a server for hoarding purposes. It will have data…
THX1137
  • 903
  • 6
  • 15
2
votes
1 answer

Non-stop requests over sente web-socket channel for what should be a single request

The goal is to allow someone to update the status of an online exam in real time. (IE. Pressing Activate Charlie's exam, changes Charlies screen to allow him to start taking his exam. The relationship between the proctor is one proctor to many…
2
votes
1 answer

How to run the backend server/code in re-frame template?

Using lein re-frame template I see that there's a -main function that runs a jetty server for the backend code located in clj/. Using emacs I've been able to cider-jack-in-cljs and get the frontend running in the browser, hot reload works and all…
stigma
  • 338
  • 2
  • 12
2
votes
1 answer

How to use use React libraries in ClojureScript

I'm trying to use cljsjs/vis in my re-frame / reagent / leiningen project, but getting the error when import this library into namespace. cljsjs/vis in namespace required but not available Have tried to use another libraries for charts/data…
Axel13
  • 23
  • 3
2
votes
2 answers

ClojureScript. Reset atom in Reagent when re-render occurs

I'm displaying a set of questions for a quiz test and I'm assigning a number to each question just to number them when they are shown in the browser: (defn questions-list [] (let [counter (atom 0)] (fn [] (into [:section] …
aarkerio
  • 2,183
  • 2
  • 20
  • 34
2
votes
2 answers

Why are there clj and cljs folders in my lein re-frame template?

Why are there clj and cljs folders in my lein re-frame template as below? And why do they both include files called .core that appear to use the same namespaces? I've been told this is the place to start when learning re-frame, but I cannot find any…
Mr. Robot
  • 1,334
  • 6
  • 27
  • 79
2
votes
1 answer

lein re-frame template - No :main namespace specified in project.clj

I have followed the readme from the lein new re-frame template exactly, but I get the error: No :main namespace specified in project.clj. I know this is a well documented error, but when I add the line :main my-first-reframe-app.core…
Mr. Robot
  • 1,334
  • 6
  • 27
  • 79
2
votes
2 answers

How do I extract metadata from a var when a function returns its symbol?

I'm using re-frame with spec to validate app-db, much like in the todomvc example. When a user makes an invalid entry, I'm using s/explain-data (in a re-frame interceptor) to return a problems map naming the :predicate which caused validation…
Jeremy Field
  • 652
  • 7
  • 12
2
votes
1 answer

Deriving static CSS from React components in ClojureScript

I've been playing around and thinking about using React through its various abstractions in ClojureScript, Reagent, Rum, Re-frame and Om. But there's one thing that I'm not sure that either adresses, perhaps because its a separate concern depending…
Rovanion
  • 4,382
  • 3
  • 29
  • 49
1 2
3
9 10