Fork me on GitHub
#untangled
<
2016-07-19
>
jasonjckn18:07:08

@currentoor: nice I've already written something very similar to boostrap.cljs there

jasonjckn18:07:18

@currentoor: so you append "Ui" right for the factory function?

jasonjckn18:07:35

@currentoor: it's too bad I can't get the @ReactClass syntax to work in advanced mode

jasonjckn18:07:50

i liked the syntax, but I suppose I can type 1 more character

currentoor18:07:57

@jasonjckn: yeah i've copied over that bootstrap macro too many times from project to project now 😄

currentoor18:07:29

your syntax does look cooler though but yeah i don't mind typing one extra character

jasonjckn18:07:34

i'm definitely going to steal some stuff from aum.cljc

currentoor18:07:01

it's on clojars by the way

jasonjckn18:07:18

my syntax also helped for writing generic code, e.g:

(def tabui-list
  [ListingsTab
   BookingsTab
   MessagesTab
   ReportsTab
   TXJTab
   SpaceTransferTab
   InviteUserTab
   CreateBookingTab
   NewCollectionsTab])

(def which-tab->tabui
  (zipmap (map #(:which-tab (initial-state % nil)) tabui-list)
          tabui-list))

(defui TabUnion (map-vals get-query which-tab->tabui)

  static Ident
  (ident [T {:keys [which-tab]}] [which-tab :tab])

  static InitialAppState
  (initial-state [_ _] (initial-state MessagesTab))

  Object
  (navbar [T which-tab]
    (nav {:bsStyle "pills"
          :stacked true
          :class "nav"
          :activeKey which-tab
          :onSelect #(transact! T [(app/choose-tab {:tab (keyword %)})
                                   (history/commit)
                                   :ui/react-key])}

         (for [[which-tab tabui] which-tab->tabui]
           (nav-item {:eventKey which-tab} (tab-title tabui)))))

  (render [T]
    (let [{:keys [which-tab]} (props T)]
      (div
       (.navbar T which-tab)
       (div {:id "tabunion_content"}
            (@(which-tab->tabui which-tab) (props T)))))))

currentoor18:07:20

if you have any good ideas i'm open to suggestions

jasonjckn18:07:40

so

(@(which-tab->tabui which-tab)
is harder to do with the "Ui" syntax

currentoor18:07:11

yeah definitely, i'm trying to think of how i would do that

jasonjckn18:07:19

@currentoor: i was thinking of putting props as an argument into render function for sugar reasons

currentoor18:07:26

oh my god yes!

currentoor18:07:58

i've had the same thought every time i write a render method!

currentoor18:07:58

just been too lazy

currentoor18:07:09

i want destructuring to still work though

jasonjckn18:07:14

yah, i just have higher priority stuff, so haven't bothered to do it

currentoor18:07:53

i've done something kind of similar in clojure land by wrapping an anonymous function, otherwise generic destructuring didn't work

jasonjckn18:07:20

(let [args [k# env# pull-result#]] @body)

currentoor18:07:04

i think i tried that initially but namespaced keywords didn't behave correctly

currentoor18:07:45

either way, if you get to it first definitely let me know, i'd love to add props as an argument to the render method

jasonjckn18:07:20

would you add computed props and props as 2 arguments?

currentoor18:07:56

it'd be cool to make render variadic and allow (render [this]...) or (render [this props]...) or (render [this props state]...)

currentoor18:07:25

hmm, hadn't thought of computed props

jasonjckn18:07:01

yah something doesn't quite feel right about all this sugar

jasonjckn18:07:11

maybe because protocols can't be variadic

jasonjckn19:07:01

i cheated while debugging this, I copied the CLJS code into CLJ , then ran Cider debugger on it and stepped through the code line by line 🙂

jasonjckn19:07:03

i suppose I could have used chrome dev tools as well to debug it

jasonjckn19:07:13

not sure it has locals though

tony.kay20:07:21

@adambros: Anthony, mind taking a look at his PR?