Fork me on GitHub
#re-frame
<
2018-04-08
>
danielcompton09:04:59

@matthewdaniel It’s fine to put it on every event, re-frame-10x drops old events (only keeps 5 by default), so it shouldn’t cause a problem, and if it does, please report it as ideally we’d like to have it on everything eventually

danielcompton09:04:11

I’ve got a new feature coming which does ‘lazy’ printing of data structures, so if you only print the first 20 characters of a 20Mb map then you only pay a very small amount for it

MegaMatt11:04:41

when i have 10x open my css transitions are a bear. they kinda freeze the browser for up to a second or more. hiding the bar will turn the transitions back to normal speed.

danielcompton12:04:53

Which panel are you on?

danielcompton12:04:17

Same on all panels?

MegaMatt13:04:28

@U051KLSJF it is the worst on event. it is minimally there on the rest but usually negligible

danielcompton01:04:55

Ok, the new version should be much faster there

javi12:04:22

@al.vyguzov I settled on 2 simple wrappers given

(def data-model
  {:re-app {:counter       0}}) ;;<-- :re-app will be the namespace
  
a wrapper for events
(defn reg-event-ns
      ([event-name interceptors handler]
        (rf/reg-event-fx
          event-name
          interceptors
          (fn [{:keys [db]} evt]
              (let [ns (keyword (namespace event-name))]
                   {:db (assoc db ns (handler (db ns) evt))}))))
      ([event-name handler]
        (reg-event-ns event-name [] handler)))
and one for subs
defn reg-sub-ns
      [sub-name handler]
      (let [ns (keyword (namespace sub-name))]
           (rf/reg-sub
             sub-name
             (fn [db evt]
                 (handler (db ns) )))))
used like so
(reg-event-ns
  :re-app/inc ;;<-- :re-app ns
  (fn [db [_]]
      (update-in db [:counter] inc)))
	  
(reg-sub-ns
  :re-app/counter ;;<-- :re-app ns
  (fn [db [_]]
      (get-in db [:counter])))	  
(edit: wrong ns)