Fork me on GitHub
#re-frame
<
2016-09-16
>
borkdude11:09:19

Iā€™m starting to enjoy Re-frame. Just saying šŸ™‚

nbenari12:09:44

Hi, I upgraded reagent from 0.5.0 to 0.6.0 and now I get "Reaction is read only" which I did not see before. How do I make a mutable ratom from a subscription?

andre16:09:11

my lib is specially for the re-frame, it analyzes clojure code and generates re-frame pattern data structures

andre16:09:03

so if you have re-frame view (component ) , it automatically shows subscriptions and dispatches related this view (component)

richiardiandrea17:09:42

It looks cooler and a bit more targeted to re-frame apps, which is what I was looking for...at the moment I am personally using https://github.com/Odinodin/data-frisk-reagent

andre17:09:41

yes, i'm using this lib to render data

shaun-mahood18:09:54

@andre: Is that open source? Looks very interesting and useful!

andre18:09:52

if you are interesting guys i will make some cosmetic improvements and open source it, i want to add code tooltips to see query (sub) code

shaun-mahood18:09:39

@andre: Very interested, that would be great!

coyotespike20:09:44

I'm trying to add an undo button to the re-frame todomvc example. After reading the new tutorial on Interceptors, it's my understanding that a chain of interceptors is just a vector. Further, the undo function is just an interceptor. Therefore I should be able to add it to an existing vector of Interceptors, like so:

(reg-event-db
 :clear-completed
 (conj todo-interceptors (undoable "un-clear all completed))
  (fn [todos _]
    (->> (vals todos)                ;; find the ids of all todos where :done is true
         (filter :done)
         (map :id)
         (reduce dissoc todos))))    ;; now delete these ids

coyotespike20:09:23

And then, going by the undo documentation at https://github.com/Day8/re-frame-undo, I should just be able to fire off the pre-defined #(dispatch [:undo]) function.

coyotespike20:09:13

With all this in place, the button hasn't un-done, it seems šŸ˜‰

coyotespike20:09:38

Actually I'm wrong - (undoable) is an Interceptor factory, not an Interceptor. So I'd expect it to behave differently.

coyotespike20:09:16

Which still leaves me wondering how to add it to an existing chain of interceptors at the top of an event handler.

mikethompson21:09:29

@coyotespike

(reg-event-db
 :clear-completed
  [todo-interceptors (undoable "clear all completed")]                    ;; <--   should work 
  (fn [todos _]
    (->> (vals todos)                ;; find the ids of all todos where :done is true
         (filter :done)
         (map :id)
         (reduce dissoc todos)))) 

mikethompson21:09:02

Note: you can compose interceptors like this: [interceptor1 interceptor2 [interceptor3 interceptor4]] (notice the nested vectors). re-frame will flatten the structure and remove nils. That's why you can put todo-interceptrors into a further wrapping vector - no need for conj. Note: you would normally give a string which describes the action (not the undo of the action). Later you can give them the option to undo "clear all completed".

shaun-mahood21:09:34

Throwing a couple re-frame proposals (one in so far, one still to come) into the #conf-proposals channel if anyone is interested in giving feedback.

coyotespike21:09:58

@mikethompson Thanks a lot, it worked! How exciting, though I coulda sworn I'd tried that one. And I've made note of your notes. šŸ˜Ž