Fork me on GitHub

Maybe an odd question but I really like the pattern for state management with re-frame however the CLJS prototype I’m using is more of a JS SDK to be consumed by other libraries (baby steps, boss still loves angular). There will eventually be a reagent component aspect but I’m currently only focused on the data layer. Would re-frame be useful or should I just copy the patterns?


not quite clear what you’re doing with it. However keep in mind that currently re-frame only has one global context, so it might be a little difficult to use it as an SDK for other libraries. See and for more details


I’m writing a API helper library for inhouse apps. It’s possible for it to be stateless but there’s some really cool things I can do if I can cache and keep state on some of the data being pulled down or say register an event-handler and poll the api to update a list of callback functions. Stuff like that.


But what would be most cool would be being able to allow consumers of the library to register callbacks much like react components and when the db state changes call those functions as you would update components


(I have no experience of it, I only know it exists)


We’ll I’m wanting to write this in cljs so I can have a path to coverting us completely over, by starting with a API and data layer abstraction.


I’d love to redo the whole UI in reagent but baby steps.


I’m looking through the re-frame source now and it’s not terribly complicated. I might be able to just borrow some of the patterns from there.


I’m also thinking of letting this helper library be compatable with Clojure or Node so I can get multiple target envs. So maybe re-frame would be bad either way.


Yeah, there's not a lot to re-frame. A few hundred lines of code (a bit more if you include undo related stuff).


But it does get to leverage both Reagent and React obviously, which is a pretty big leg-up.


totally and what I’ll probably do is circle back to using them if I can convince the rest of the team to do the view layer in cljs


Hello guys, just something is bothering me a bit about async testing (it may be it will be very silly): I would like to perform the following test in re-frame (I know the code below is going to be wrong):

(deftest require-test
  (async done
      (dispatch [:evaluate-form "(require 'clojure.string)"])
      (let [res (subscribe [:get-console-answer])]
            (is (= @res val)) <- this is not blocking so I cannot wait for it to happen


do I need to mock my handlers for this?


ok I read all the Testing wiki, probably not straightforward this one


it would be great to have something that transforms a reaction in a channel to wait on, ah wait, I have watches 😉


So, it seems to me you need to test: 1. The event handler does the right thing. 2. That the subscription handler does the right thing So that's two simple tests, rather than one complicated one.


@mikethompson: yes I agree with that I read that file 5 mins ago 😄


my use case is for async interactions basically the handler does the right thing if given the right amount of time


I know it's weird


but it is basically calling sync to deal with it


i'm having a really tricky problem with re-frame right now... I have a form with a file-input field. I trigger the upload of the file with an event. When the upload is finished, I would like to clear the input field (i.e. set its value attribute to the empty string).


Usually I would do that by specifying the value prop on the input field and then set up a subscription to the application state


but in this case it won't work, since I can programmatically only set the input's value to the empty string (seems to be a security thing)


@jbaiter: is it a re-frame issue or a browser issue?


happy to help either way, but just trying to be clear on the problem


In the default re-frame template +secretary how would one pass a variable to a panel? I have a couple of top-level components and for two of them I would like to pass in a variable. Is there a better way/alternative way to do this?