untangled

NEW CHANNEL: #fulcro
2016-07-19T18:20:08.000081Z

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

2016-07-19T18:20:18.000082Z

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

2016-07-19T18:20:35.000083Z

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

2016-07-19T18:20:50.000084Z

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

currentoor 2016-07-19T18:21:57.000085Z

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

currentoor 2016-07-19T18:22:29.000086Z

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

2016-07-19T18:22:34.000087Z

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

currentoor 2016-07-19T18:22:51.000088Z

nice 😄

currentoor 2016-07-19T18:23:01.000089Z

it's on clojars by the way

2016-07-19T18:23:18.000090Z

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)))))))

currentoor 2016-07-19T18:23:20.000091Z

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

2016-07-19T18:24:40.000092Z

so

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

currentoor 2016-07-19T18:26:11.000093Z

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

2016-07-19T18:26:19.000094Z

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

currentoor 2016-07-19T18:26:26.000095Z

oh my god yes!

currentoor 2016-07-19T18:26:58.000096Z

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

currentoor 2016-07-19T18:26:58.000097Z

just been too lazy

currentoor 2016-07-19T18:27:09.000098Z

i want destructuring to still work though

2016-07-19T18:27:14.000099Z

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

currentoor 2016-07-19T18:27:53.000100Z

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

2016-07-19T18:32:52.000102Z

use a let ?

2016-07-19T18:33:20.000103Z

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

currentoor 2016-07-19T18:34:04.000104Z

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

2016-07-19T18:34:12.000105Z

k

currentoor 2016-07-19T18:34:45.000106Z

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

2016-07-19T18:35:20.000107Z

would you add computed props and props as 2 arguments?

currentoor 2016-07-19T18:35:56.000108Z

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

currentoor 2016-07-19T18:36:25.000109Z

hmm, hadn't thought of computed props

2016-07-19T18:37:01.000110Z

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

2016-07-19T18:37:11.000111Z

maybe because protocols can't be variadic

currentoor 2016-07-19T18:37:27.000112Z

true

2016-07-19T19:37:01.000115Z

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 🙂

2016-07-19T19:38:03.000116Z

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

2016-07-19T19:38:13.000117Z

not sure it has locals though

tony.kay 2016-07-19T20:11:21.000118Z

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