Fork me on GitHub

It works like a charm, you kinda just need to make sure the server will return index.html for everything that is’nt a resource/file on the server


or you make the server to return index specifically for the pages of your spa


how do you guys set intervals on re-frame?


like, something to periodically dispatch an event for example


js/setInterval on did-mount, and teardown on will-unmount?


This is how i usually do it, not re-frame specific.


i am doing that, actually i should have asked if you guys use some standard effect for that


i was wondering about if it was correct to dispatch events from effects


but i found an example showing that this is ok


I do this:

  (fn [cofx [_ opts]]
    (let [{:keys [db]} cofx
          {:keys [interval-ms on-tick id]} opts]
      {:db (assoc-in db [:timers id] (assoc opts :status :started))
       :dispatch-later [{:ms interval-ms :dispatch [:timer/tick id]}]})))

  (fn [cofx [_ id]]
    (let [{:keys [db]} cofx
          {:keys [interval-ms on-tick id status]} (get-in db [:timers id])]
      (when (= status :started)
        {:dispatch on-tick
         :dispatch-later [{:ms interval-ms :dispatch [:timer/tick id]}]}))))

  (fn [db [_ id]]
    (update-in db [:timers id] assoc :status :stopped)))


Probably not as good as setInterval though


@mateus.pimentel.w I'm using Pedestal on the back end and could use some guidance for the following goal: I want "/" to go to a static landing page with a different CSS style altogether than the portal at "/admin" that the user logs into through "/admin/login". Since re-frame apps mount a div by ID, I don't seem to have the control I want over the HTML document as a whole. When I slurp a different index.html for admin at "/admin" in my Pedestal routes configuration, Bidi always gives me the "page not found" view (see re-frame-starter at github). even though I defined the route as ["\" {"admin" :homepage ...}]. Anything under that, goes through Pedestal's routing. bidi can't seem to handle not being off "/" as the starting point for the SPA, or I just don't know how to make it work right with Pedestal for my specific needs. In any case, if I can find some way instead to support multiple page designs, I would be happy with one SPA for the front and back ends, and Bidi would probably work with that. Can re-frame/reagent take over the whole document, or must I always mount a named div?


Where can I rent a re-frame expert for an hour or two? Berlin would be nice, but anywhere really is fine.


@bob592 you need pushy to do what you want


pushy + bidi


@mateus.pimentel.w OK i'll look into that.


@bob592 that article i sent you is like an walkthrough, i think you will have success following it

Braden Shepherdson20:12:15

I want to make a layer-3 subscription with two inputs, but that only updates when one of those inputs is changed.

Braden Shepherdson20:12:41

I suppose there's some way to make that work properly with reg-sub-raw.


What’s a nice way to prevent the app-db being completely reset when a user refreshes the page?

Braden Shepherdson20:12:24

you can fairly seamlessly persist all or parts of the app-db to and from localstorage, for example.


Yeah that’s the first place my head went to, too.


@mikethompson have you dug into how re-frame’s dispatch queue fits in with React’s new async rendering / “Concurrent Mode”?


is it even necessary? it sounds like React basically does prioritization of each event now