re-frame

https://github.com/Day8/re-frame/blob/master/docs/README.md https://github.com/Day8/re-frame/blob/master/docs/External-Resources.md
jdkealy 2020-06-17T14:57:03.408Z

When running figwheel it seems none of my subscriptions reload. Is there some setting or coarse of action I need to take to use figwheel properly with re-frame ?

lepistane 2020-06-17T15:27:14.412100Z

how did you solve this issue i created an app (react native) that deals with orientation a lot and there are a lot of places where UI should change based on orientation so i decided instead of having subscribe to orientation all over the app instead id abstract default view and just use that component but i run into a problem.

(defn view [& [props & children]]
  (let [config (rf/subscribe [:app-config/all])]
    (fn []
      (let [{:keys [orientation]} @config]
        (reduce (fn [base child]
                  (conj base child))
                [:> rn/View (merge {:style {:flex 1
                                            :flex-direction orientation}}
                                   props)]
                children)))))
This is the view abstraction but when i use it like
[comps/view
         {}
         [:> rn/View {:style {:flex 1
                              :padding 10
                              :justify-content :space-around
                              :align-items :center
                              :background-color :red
                              }}

          [:> rn-elem/CheckBox {:center true
                                :title "BUY"
                                :checked-icon :dot-circle-o
                                :unchecked-icon :circle-o
                                :checked (= @action :buy)
                                :on-press #(reset! action :buy)
                                :checked-color :black}]
          [:> rn/Text {:style {:font-weight :bold
                               :font-size 24
                               :color :black}} "OR"]
          [:> rn-elem/CheckBox {:center true
                                :title "SELL"
                                :checked-icon :dot-circle-o
                                :unchecked-icon :circle-o
                                :checked (= @action :sell)
                                :on-press #(reset! action :sell)
                                :checked-color :black}]]
         (if (= :buy @action)
           [buy-details @option @gameplay (second selected-option)]
           [sell-details @option @gameplay (second selected-option)])]
it is as though option gameplay and action are non existent, like reactions are not happening, checkboxes don't work. What i think is happening is that view component's scope doesn't see option, gameplay or action and it fails. is there a way to deal with this? any way to make it work? i'd appreciate feedback on the approach as well. Should i be doing this in a different way?

lepistane 2020-06-18T10:45:32.438200Z

managed to get it working with

(defn view [& [props & children]]
  (let [config (rf/subscribe [:app-config/all])]
    (reduce conj [:> rn/View (merge {:style {:flex 1
                                             :flex-direction (:orientation @config)}}
                                    props)]
            children)))
the question i have now is why the other one was breaking

lepistane 2020-06-18T11:56:23.439200Z

SOLVED:

(defn view
  "reference <https://github.com/reagent-project/reagent/blob/master/doc/CreatingReagentComponents.md#form-2--a-function-returning-a-function>"
  [&amp; [props &amp; children]]
  (let [config (rf/subscribe [:app-config/all])]
    (fn [&amp; [props &amp; children]]
      (let [{:keys [orientation]} @config]
        (reduce conj [:&gt; rn/View (merge {:style {:flex 1
                                                 :flex-direction orientation}}
                                        props)]
                children)))))