Fork me on GitHub
#re-frame
<
2016-06-14
>
bpicolo02:06:22

Anybody have experience with https://github.com/reagent-project/reagent-forms ? I'm having trouble getting the form to refresh after data is loaded

mikethompson10:06:36

I've finally got around to documenting re-frame's built in undo/redo. https://github.com/Day8/re-frame/wiki/Undo-&amp;-Redo

tawus12:06:27

Can we do an ajax call within a dynamic subscription ?

symbit14:06:26

@darwin profile is just a "String" indicating which profile to use.

darwin14:06:06

yes, that was the “edn" solution

darwin14:06:06

if your profile is just a string, instead of var edn, create var myString and emit that string there directly, without pr-str and read-string

darwin14:06:47

but be aware that you should escape that string, so it does not contain quotes, etc. so it is a valid javascript

danielcompton22:06:34

@tawus yep, that was the first use case for dynamic subscriptions (we were using websockets, but same principle)

javazquez22:06:18

any recommendations on local storage solutions to use with re-frame?

tawus22:06:25

@danielcompton: If I understand correctly, the dynamic subscription should return the newly calculated value but with an ajax call, how can we do that ? Sorry if it is something obvious.

javazquez22:06:44

I see that the todos example uses 'js/localStorage' , but came across a few other options and thought I would ask for guidance 🙂

danielcompton22:06:17

@javazquez: alandipert has a local storage atom lib

danielcompton22:06:08

The dynamic subscription will return a ratom which will initially be empty, then when your result comes back, it will swap the result into that ratom

danielcompton22:06:24

We tend to do side effecting things through handlers now though

danielcompton22:06:41

So there would be a request for data, which would callback to a handler when data was received

darwin22:06:21

@symbit: ah, you had the parameter already present in url, so it is kinda pointless to emit it as javascript variable, url parameters can be easily read from javascript

javazquez23:06:27

thanks @danielcompton, trying to understand the how to "wrap" the ratom from db.cljs

javazquez23:06:34

is the advice to create a separate atom for this library and update it in the handlers ?

danielcompton23:06:11

(register-sub
  :sub-side-effect
  (fn [db [_ params]]
    (let [ratom (r/atom {:status :pending})]
      (ajax/call "" params
        :on-success #(reset! ratom %)
        :on-error #(reset! ratom %))
      ratom)))

danielcompton23:06:22

something like that, that’s just pseudo code