Fork me on GitHub
#om
<
2016-04-27
>
mattyulrich01:04:56

I do have a hierarchy of components… Just stripped it down to the minimum and I still see it:

mattyulrich01:04:39

App-Root has a query of ‘[:user] and creates an App-Header (header om/props this); Header has a query of ’[:user] and creates a Login-Component (login om/props this); Login-Component has a query of ’[:user]…. There’s no complaint when the page loads and app-state is empty; but when a user logs in and I mutate the app-state to add :user, I get that error.

tomjack03:04:57

your queries don't really make sense

tomjack03:04:24

usually you will see, for your example, something like this:

tomjack03:04:44

AppRoot: [{:header (om/get-query Header)}]

tomjack03:04:01

Header: [{:login (om/get-query Login)}]

tomjack03:04:07

Login: ...

tomjack03:04:30

with (header (:header (om/props this))), (login (:login (om/props this))) etc

tomjack03:04:53

you can see how, starting with App-Root, there is a 'path' in the queries to Header and then to Login with get-query. this is what the error is complaining about -- you don't have that in your queries

mattyulrich03:04:04

Ok… I think this makes a lot more sense… I don’t think I’ve really gotten a handle on the query syntax; what ‘get-query’ returns and where it fits. I’ll play with this; thanks for the feedback!

tomjack03:04:34

It may be confusing that the metadata of values returned by get-query is important

jimmy05:04:20

@kendall.buchanan: if you want to mix the project, your best bet is to mount react component to om. I have heard that CapitalOne has tried the approach of using both cljs and js. I'm not so sure about their approach and how they did it ( curious to know too )

wilkerlucio11:04:43

Hello People, I'm trying to use a parameterized query with Om alpha-34 but I'm getting an error:

wilkerlucio11:04:00

(om/query->ast [({:some/key [:sub/key]} {:arg :foo})]) -> #error {:message "Invalid expression ", :data {:type :error/invalid-expression}}

wilkerlucio11:04:25

I'm pretty sure it was working before, does someone else can reproduce that?

anmonteiro11:04:41

@wilkerlucio: try quoting the query?

anmonteiro11:04:56

you need to actually do that because of ()

wilkerlucio12:04:15

@anmonteiro: oh, you right, thank you simple_smile

wilkerlucio12:04:22

sorry, missed that big time

devth12:04:40

i'm using om's default-merge in my reconciler. should i expect :tempids maps from remote mutations to automatically be resolved in my app state?

devth12:04:15

or do i need to process them myself and update the appropriate app state?

thomasdeutsch14:04:49

looking for advice on how to do advanced compilation with om.next. When i simply try the :advanced compiler option, i get this error:

goog.require could not find: cljsjs.react

hlolli14:04:07

You should not need to add cljsjs.react manually, but om.next depends on it. Try this in :dependencies

[org.omcljs/om "1.0.0-alpha32"
                  :exclusions [[cljsjs/react]
                               [cljsjs/react-dom]]]
[cljsjs/react "15.0.1-1"]
[cljsjs/react-dom "15.0.1-1"]

iwankaramazow15:04:29

@devth: you might check default-migrate instead of default-merge 😄

tmorten15:04:19

Has anyone attempted passing an api key/token from app-state to their send function? Is the best way to merge in the token into the ast...i.e. {:server-api-remote (assoc ast :api-remote-token (get st :api-token))}...?

paul-c16:04:14

@tmorten I've done it by merging into the ast's params (update ast :params merge {:api-remote-token (get st :api-token)} params)

tmorten16:04:48

Looks like that is a good place for it. Thanks @paul-c

currentoor18:04:32

Is it ok to call transact! inside componentWillMount?

currentoor18:04:51

assuming the mutation will not cause the component to remount?

jimmy18:04:34

@tmorten: you might want those info in your req header.

tmorten19:04:49

@nxqd: yes, I set request headers in my send method. Similar to the om-next-todo demo application

tmorten19:04:13

I'm just thinking once someone "logs" most would save the api-token to the application state...so from the app state, I was wondering what best practices are in getting that to the actual send method to update the request headers...

iwankaramazow19:04:59

@tmorten: send is a function, if you pass the reconciler in it, you have access to the state

tmorten19:04:43

@iwankaramazow: That is an even better idea...there maybe a few other things I'd like to send in the request as well...

iwankaramazow19:04:56

@tmorten: passing the reconciler to send is a bit tricky in terms of circular dependencies, you could try something like this:

(defn make-reconciler
  [{:keys [state parser merge merge-tree migrate id-key]}]
  (let [escape-hatchet (atom nil)
        config {:state state
                :parser parser
                :migrate migrate
                :id-key id-key
                :merge merge
                :merge-tree merge-tree
                :send (transit-post "/api" (assoc {} :reconciler  escape-hatchet))}
        reconciler (om/reconciler config)]
    (reset! escape-hatchet reconciler)
    reconciler))

tmorten19:04:51

interesting...