hyperfiddle-2020 icon indicating copy to clipboard operation
hyperfiddle-2020 copied to clipboard

Widgets migrate to (f e a rets adds)

Open dustingetz opened this issue 5 years ago • 4 comments

Here is what the picker interface could look like

(defmethod hf/render #{:rosie.hyperfiddle.sub/locations :swing/display-sub} [ctx props]
  #?(:cljs
     [picklist
      (assoc ctx
        ; This way is too much programming, not declarative enough
        ::hf/view-change! (fn [ctx]                         ; no longer needed
                            (fn [os ns]                     ; [e a rets adds]
                              (let [rets (set/difference os ns)
                                    adds (set/difference ns os)]
                                (runtime/with-tx ctx        ; lift up and parameterize
                                  (location-picker-tx (hf/e ctx) :sub/tags rets adds)))))

        ; Better way
        ::hf/with-tx! runtime/with-tx
        ::hf/view-change! (fn [e a rets adds]
                            (location-picker-tx e :sub/tags rets adds)))
      (merge props
        {:html/id        `sub-locations-picker
         ::hf/needle-key :needle
         :options        :swing/all-locations})]))

Note the route-change interfaces need to be thought through. Does (hf/swap-route! ctx assoc needle-key n) make sense with [e a rets adds]?

Acceptance criteria

  1. pickers work like this
  2. good strategy for routestate pickers
  3. other widgets are migrated (string, date, etc)

dustingetz avatar Jul 18 '20 22:07 dustingetz

https://github.com/hyperfiddle/hyperfiddle/commit/8aafcc5882a7215d957177ad633fdb80f4fce72a

dustingetz avatar Jul 19 '20 18:07 dustingetz

(defmethod hf/render #{:rosie.hyperfiddle.sub/locations :swing/display-sub} [ctx props]
  #?(:cljs
     [picklist
      (assoc ctx
        ; Better way
        ::hf/target ::hf/route ; <--- dispatch to multimethod, default would be stage
        ::hf/view-change! (fn [e a rets adds]                            ; This could be (have) a default value
                                        (location-picker-tx e :sub/tags rets adds)))
      (merge props
        {:html/id        `sub-locations-picker
         ::hf/needle-key :needle
         ::hf/options        :swing/all-locations})]))

Invocatis avatar Jul 21 '20 19:07 Invocatis

Luke says: Let's slow down, unsure if this is the right thing.

dustingetz avatar Jul 24 '20 14:07 dustingetz

Luke says: Don't know where the old value comes from, is this from debounce? Not all controls use debounce

dustingetz avatar Jul 24 '20 14:07 dustingetz