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
0 answers

No protocol method defined for type object: :empty

I'm trying to fix a bug in a Clojurescript frontend using Reagent and Re-frame. I find the error messages a little difficult to decipher at times and I can't crack this one. All I know is that I'm getting a bug in a particular view like this: No…
StormKrow
  • 875
  • 1
  • 6
  • 10
0
votes
1 answer

Writing a plugin file in ClojureScript for use in CKEditor

I currently have a project that is using ClojureScript, shadow-cljs, re-frame, and CKEditor. I am trying to figure out how to write a custom plugin for CKEditor usoing CLJS instead of JS. CKEditor uses the following to load external custom…
0
votes
1 answer

how do I remain the changed value in clojure reframe

Suppose I have a group of buttons and if user clicked a button I want it to change the value from "not clicked" to "clicked" so I have wrote this code (rf/reg-sub ::clicked-sub (fn [db _] (:clicked db))) (rf/reg-event-db ::clicked-event (fn…
Patrick
  • 734
  • 11
  • 26
0
votes
1 answer

Reagent Component not Re-Rendering on Prop Change

My Reagent component ist a simple div that has a component-did-mount and a component-did-update hook. It draws notes using vexflow. (defn note-bar [notes] (reagent/create-class {:display-name "Note Bar" :reagent-render (fn…
0
votes
0 answers

Re-frame dispatches and subscribes not working in the repl and test files

I have a re-frame project, and my events, subs and db cljs files are populated. I use these three in my project and it works well. But I created a test file, and called subscribe and dispatch in it like so: (deftest category-filter-test (dispatch…
zendevil.eth
  • 974
  • 2
  • 9
  • 28
0
votes
1 answer

Select/unselect checkbox in re-frame

I'm adding a search id element to my app-db with: [:input {:type "checkbox" :on-change #(reframe/dispatch [:add-elm {:subject_id subject-id}])}] but I don't know how to recognize when the final user is checking or unchecking the box in order to…
aarkerio
  • 2,183
  • 2
  • 20
  • 34
0
votes
1 answer

How to serve the correct panel in reframe based on the uri?

I have several panels defined for my app like so: (defmulti panels identity) (defmethod panels :panel1 [] [panel1]) (defmethod panels :panel2 [] [panel2]) (defmethod panels :panel3 [] [panel3]) I can use bidi+pushy in the client side to push a…
zengod
  • 1,114
  • 13
  • 26
0
votes
1 answer

multi-panel reframe not working as expected

I have the following reframe code: ;;sub (reg-sub :active-panel (fn [db] (:active-panel db))) ;;event (reg-event-db :active-panel (fn [db [_ new-panel]] (assoc db :active-panel new-panel) )) (defn another [] (fn [] [:div …
zengod
  • 1,114
  • 13
  • 26
0
votes
0 answers

How to correctly save the value of a text input into the db in reframe?

I'm handling a text input using reframe like so: [:input { :type "text" :value @(subscribe [:text-bar]) :on-change #(dispatch [:text-bar-input (-> %…
zengod
  • 1,114
  • 13
  • 26
0
votes
1 answer

How to reset a counter in Re-frame (ClojureScript)

This must be one of those silly/complex things that everybody founds when learning a new framework. So I have this function: (defn display-questions-list [] (let [counter (atom 1)] [:div (doall (for [question @(rf/subscribe…
aarkerio
  • 2,183
  • 2
  • 20
  • 34
0
votes
1 answer

How to change state (src of img) clojurescript component after reagent-render with click events

We have touching clojurescript code, but when the image changes when clicking a thumbnail the selected image needs to render with zoomer. We start clicking the thumbnail, this changes the atom with the selected image, and passes to the zoomer…
0
votes
1 answer

How to add shadow cljs watcher on js directory in a re-frame app?

I have created a basic re-frame app using the template lein new re-frame my-proj. This particular project is interfacing with a framework (ecsy) that requires some ES6 modules and ES6 classes e.g code that is generated by the user, not simply…
vt5491
  • 2,254
  • 2
  • 22
  • 34
0
votes
1 answer

reset! on reagent atom doesn't work as intended

So what I'm trying to do is a basic tabbed view using re-com's horizontal-tabs element. I added a v-box element and below that i want to have my tabs element and the body that corresponds to the tab. although on the :on-change i call reset! on the…
Nikolas Pafitis
  • 153
  • 1
  • 1
  • 8
0
votes
1 answer

Can i store my app's content (reagent components) in the re-frame db?

Here is my app's structure: (reg-event-db :app-surface-add-layer! (fn [db [_ layer-content & [layer-params]]] (assoc db :app-surface-layers (conj (:app-surface-layers db) {:layer-content layer-content …
0
votes
1 answer

ClojureScript function prints strings, but will not return hiccup

I have a ClojureScript component: (defn main-panel [] (def nodes (-> @(re-frame/subscribe [::subs/nodes]))) (defn list-nodes [node] (prn (node :name))) (reagent/create-class {:component-did-mount (fn [] …
Mr. Robot
  • 1,334
  • 6
  • 27
  • 79
1 2 3
9
10