Fork me on GitHub
#om
<
2016-08-19
>
jasonjckn18:08:27

@ethangracer what's wrong with wrapping recharts in an OM object

jasonjckn18:08:43

just boilerplate?

ethangracer18:08:03

pretty much, yeah

ethangracer18:08:20

nothing wrong with it, just tedious if you want to do it for a large number of components

ethangracer18:08:33

also @jasonjckn can’t use om/factory on non-om components

ethangracer18:08:44

which makes me wonder if rendering a non-om component from a non-om factory would cause issues (indexer, reconciler, etc.)

jasonjckn18:08:17

well you could use (om/ui ... ) to wrap it

jasonjckn18:08:40

(defn react-to-om [react query ident] (om/ui IQuery (query [] query) Ident (ident [] ident) Object (render [] react )

ethangracer18:08:14

hadn’t seen that function before

jasonjckn18:08:45

i this hack so that I don't have to create factories

jasonjckn18:08:00

(defmacro ui [q & forms]
  {:pre [(or (map? q) (vector? q) (list? q))]}

  `(let [factory-fn# (atom nil)

         new-ui# (om.next/ui
                     ~'static cljs.core/IDeref
                     (~'-deref [this#]
                      @factory-fn#)

                     ~'static om.next/IQuery
                     (~'query [this#]
                      ~q)

                     [email protected])]

     (reset! factory-fn#
             (om.next/factory new-ui# {:keyfn admin.util/uid-gen}))

     new-ui#))

jasonjckn18:08:24

(def MyNewComp (ui ...) )

jasonjckn18:08:42

MyNewComp is the om/react class, then @MyNewComp to get the factory

ethangracer19:08:40

interesting, I like that

anmonteiro22:08:51

@ethangracer I suppose that would work for the simplest case

anmonteiro22:08:32

However I fail to see a solution for e.g. children

dankweaver22:08:58

How do you all typically get the “parent” value when implementing a field? For instance my friends-list would typically depend on the user in question.

dankweaver22:08:23

if anyone is familiar with the graphql way, it would be like this:

dankweaver22:08:55

new GraphQLObjectType({
  name: 'MyType',
  fields: {
    myField: {
      type: GraphQLString,
      resolve(parentValue, args, session) {
        // use `session` here
      }
    }
  }
});

dankweaver22:08:11

parentValue is passed to resolve

dankweaver22:08:40

thank you so much

anmonteiro22:08:55

however it’s a bit of a different concept

anmonteiro22:08:08

it’s not really accessing the parent per se

anmonteiro22:08:19

but something that is “global” to the application

anmonteiro22:08:31

i.e. a top level property in your app state

dankweaver22:08:54

hmm how does this work on remotes tho.. there wouldn’t be enough context would there?

anmonteiro22:08:43

links aren’t supposed to be sent to remotes

anmonteiro22:08:14

in my experience, you’d have :foo in a top-level query and send that to the remote

anmonteiro22:08:40

once it’s fetched, queries down in the component tree can have foo with [:foo _]

dankweaver22:08:31

thank you.. this makes sense

dankweaver22:08:29

implicit arguments like current user I suppose would just be in the env that is passed to read