om

Please ask the channel first, not @dnolen directly!
baptiste-from-paris 2017-03-22T06:54:51.030089Z

@sineer it was more about displaying errors to user than validating

2017-03-22T07:29:55.294433Z

@baptiste-from-paris I investigated this before the announcement of Spec, so it is still based on Plumatic Schema, but there are some ideas here: https://github.com/plumatic/schema/issues/56

baptiste-from-paris 2017-03-22T07:31:50.311332Z

Thanks ! That's what I was talking about !

2017-03-22T07:34:07.330516Z

🙂 I would suggest doing something similar using Spec rather than going the Schema route

foobar 2017-03-22T07:42:24.399505Z

I added a new commit to my om.next/set-query! PR. I am aiming to support set-query! for datascript. https://github.com/omcljs/om/pull/857 Is this approach a good one and worth further work? Here is some illustration of the results. https://gist.github.com/sc13-bioinf/415b5bfd36b27d3a19b7f0d2ca88acda

1
2017-03-22T09:20:05.515073Z

@foobar I applaud the effort, I'd really like to see this feature.

2017-03-22T09:25:21.587141Z

I'm trying to see how it works, my immediate impression is that it's a lot of additional code. I was thinking more along the lines of an extensible interface.

foobar 2017-03-22T09:35:04.725302Z

?

2017-03-22T09:36:52.750015Z

I guess I saw it as a simple serialization/deserialization task but I'm not sure I understand everything involved.

foobar 2017-03-22T09:37:35.760256Z

Most of that is dealing with creating an index in which to store a query for each component. I didn't think that already existed (particularly for state that is not managed by om.next)

foobar 2017-03-22T09:38:36.774388Z

I could be wrong, I don't really understand om.next very well, hence asking if this is a good way to go, or the wrong tree to bark at

2017-03-22T09:40:41.804165Z

I though the index was stored on the app-state under :om.next/queries.

foobar 2017-03-22T09:41:37.817475Z

I haven't looked at that, I was only looking at the indexer, maybe I missed it

2017-03-22T09:45:38.876460Z

I previously wanted to work on this and my idea was to replace swap! update-in and get-in with an API that could be implemented for different stores (and for the implementation to be kept outside of om core). Didn't get any feedback on whether it was a good way to go so I never wrote any code, hope you get some.

foobar 2017-03-22T09:47:49.908370Z

As far as I can tell nothing reads from :om.next/queries at the moment

2017-03-22T09:50:12.942417Z

Yeah, you might be right there.

2017-03-22T09:50:56.953285Z

What benefits do you see from storing the queries on the app-state instead of the indexer?

foobar 2017-03-22T09:51:00.954448Z

I also thought that building a tree was important because I wanted to update one child and not its sibling. The parent would have to recognise that the queries of the children are now different.

2017-03-22T09:51:40.964384Z

The fact that you can persist the state somewhere and reload it I suppose.

foobar 2017-03-22T09:52:14.972278Z

E.g. in the gist, trunk begins with the static query for branch. Later on I modify the query for one of the branches

foobar 2017-03-22T09:58:13.062105Z

I would store the component queries in the indexer and not on the state. Simply because of the issue with the way its implemented at the moment and state that is not a map. Also it seems like a logical place for people to find this information.

foobar 2017-03-22T10:02:06.125488Z

There is also the possibility for people to pass their own implementations of the functions that build and query the index when using the indexer

2017-03-22T10:02:58.139150Z

Yeah, I wasn't sure. I like the idea of being able to persist/load the state and have everything exactly as it was. I'm not sure this is possible storing the queries on the indexer, unless you also persist the indexer separately.

2017-03-22T10:03:17.143767Z

I also wondered if there would be any advantages for the index to also be stored in app-state.

foobar 2017-03-22T10:03:47.151671Z

Doesn't that conflict with using set-query! ?

2017-03-22T10:04:23.160728Z

The way I understood set-query! at the moment was that it stored the queries in app-state...Although, like you said, I can't see where this information is actually used other than in merge!.

foobar 2017-03-22T10:09:42.237523Z

I think you are right although I think a call to set-query when loading persisted state is reasonable

2017-03-22T10:11:18.261083Z

Yeah but you have to know what to call it with i.e. the params, which are lost unless you persisted the indexer or your code is written in such a way that it can work it out from the state.

foobar 2017-03-22T10:11:50.268910Z

Everything can be worked out from the state.

foobar 2017-03-22T10:12:08.273233Z

Params might be trickier I admit

foobar 2017-03-22T10:14:56.313383Z

In a way one could accomplish this without set-query by creating an anon component and building the appropriate query at runtime.

2017-03-22T10:15:37.323871Z

You can accomplish everything without set-query, it's just a nice pattern/convenience.

2017-03-22T10:16:30.336395Z

If you don't use set-query! you have to do some more magic in your parsers to extract the info from state and modify the ast/query.

2017-03-22T12:16:16.872791Z

(defmethod read :ui/dropdowns
  [{:keys [state query ast user-parser] :as env} _ _]
  (let [st    @state
        route (:compassus.core/route st)
        keys  (set (keys (select-keys components (route->components route))))
        query (filterv #(contains? keys (ffirst %)) query)]
    (println query)
    {:value (assoc (user-parser env query) :route route)}))

(defmethod read :default
  [{:keys [state ast query parser] :as env} key params]
  (let [st        @state
        namespace (namespace key)]
    (condp = namespace
      "delegate"
        {:value (parser env query)}
      "remote"
        (let [name-kw (keyword (name key))
              val     (get st name-kw)]
          (println query)
          {:api   true
           :value val})
      {:value (get st key)})))
The print in ui/dropdowns gives a query like: [{:delegate/period-select [:start :end :ui/menus]} {:delegate/authors [:ui/menus]} {:delegate/category [:remote/advertisers :remote/categories :ui/menus]} {:delegate/created [:ui/menus]} {:delegate/inventory [:ui/menus]}]

2017-03-22T12:16:49.880174Z

Is there any way I can make the "remote" namespaced keywords trigger a remote query?

2017-03-22T12:19:24.913763Z

I'm using the convention that "delegate" namespaced keywords just recursively call the parser, as a way of nesting queries.

foobar 2017-03-22T12:45:38.278682Z

Wouldn't you have to send them to a read function that has those as its remotes? (also they have to be in the reconcilers list)

2017-03-22T13:02:47.546696Z

The remote is :api and my default read function returns :api true when the namespace is "remote"

foobar 2017-03-22T13:54:08.526627Z

So does it trigger your send function?

2017-03-22T13:58:55.633457Z

Nope, only if I add :api true to the read response for "delegate" but I think then I need to use process-roots somehow to only send the remote keys.

foobar 2017-03-22T14:04:53.774208Z

Wouldn't :remote/something have to be a map key in order to trigger a read?

2017-03-22T14:10:36.904055Z

Im not sure what you mean. My query looks like:

[{:delegate/period-select [:start :end :ui/menus]} {:delegate/authors [:ui/menus]} {:delegate/category [:remote/advertisers :remote/categories :ui/menus]} {:delegate/created [:ui/menus]} {:delegate/inventory [:ui/menus]}]
I only want :remote/advertisers and :remote/categories sent to the backend.

slipset 2017-03-22T14:12:15.941905Z

So, I upgraded om from 0.9.0 to 1.0.0-alpha48. Still only using om/core no om.next

foobar 2017-03-22T14:12:36.950412Z

So :delegate/category triggers your default read and you pass [:remote/advertisers to the parser?

slipset 2017-03-22T14:12:49.955423Z

When I’m using om/build-all I get the following warning in my console:

slipset 2017-03-22T14:12:51.956383Z

Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `Constructor`. See <https://fb.me/react-warning-keys> for more information.

foobar 2017-03-22T14:12:52.956646Z

Shouldn't that be [{:remote/advertisers

foobar 2017-03-22T14:13:13.964558Z

(I am just guessing here tbh)

foobar 2017-03-22T14:14:09.986956Z

Supply a unique key for each li

slipset 2017-03-22T14:14:43.999801Z

@foobar: yes, but I would have thought that that would be the job of om/build-all

slipset 2017-03-22T14:15:16.012207Z

Since it already adds an index.

foobar 2017-03-22T14:15:33.019244Z

I don't know the details of build all but I am used to supplying keys 'by hand'

slipset 2017-03-22T14:15:39.021291Z

So, by redefining build-all to

2017-03-22T14:16:07.032210Z

Yeah @foobar, I think my backend will handle it correctly as a property read or a join, not sure it matters.

slipset 2017-03-22T14:16:10.033447Z

Stuff works.

foobar 2017-03-22T14:17:16.059127Z

Its probably better if the key comes from your data though ?

slipset 2017-03-22T14:17:47.071876Z

@foobar: I could agree to that, but it kind’a makes build-all a bit useless, no?

slipset 2017-03-22T14:19:53.121976Z

@foobar how do you add the react-key to a dom/li,

slipset 2017-03-22T14:21:27.160189Z

LMGTFM 🙂

foobar 2017-03-22T14:25:36.260217Z

Something like that I think

foobar 2017-03-22T14:25:59.269532Z

Its just a guess, its a while since I used vanilla om

slipset 2017-03-22T14:26:21.278114Z

Ok, thanks, will try

slipset 2017-03-22T14:28:05.321765Z

(om/build-all dropdown-item settings {:key :text}) worked

slipset 2017-03-22T14:28:15.325730Z

@foobar Thanks a lot for your time!

2017-03-22T14:31:42.412080Z

I give up, I think i'm going to have to resort to a manual ajax request in DidMount and then a manual merge!

foobar 2017-03-22T14:34:37.484482Z

Wouldn't returning {:value something :remote/advertisers true :remote/categories} from "deletgate" trigger your send functions?

2017-03-22T14:35:16.499827Z

:remote/advertisers is not the name of the remote, it's just a property read.

2017-03-22T14:35:51.514330Z

I can trigger a send by returning {:api true} from delegate but it isn't re-rooted and doesn't contain the actual keys I wanted for the backend.

2017-03-22T14:36:26.528716Z

I used the :remote/ namespace just so I could identify the keys intended for the remote and try to fiddle with the ast and re-root it somehow. Couldn't work it out though.

2017-03-22T14:42:54.687881Z

I think I can hack it by repeating the queries in my nested dropdown queries in the root component, so that the read triggered by the dropdown ends up being a local-only one.

2017-03-22T14:43:10.694182Z

Until I can get my head around it.

puppybits 2017-03-22T15:54:50.563641Z

I'm using re-natal with om-next but whenever I call set-query! with any class other than the root I get an error No queries exist for component path (fskl.ios.core/AppRoot fskl.ios.tabbar/TabBar). Any idea what I'm doing wrong?

(om/set-query!
     (om/class-&gt;any reconciler fskl.ios.tabbar/TabBar)
     {:params {:active-date (t/date-time 2017 3 10)}})))
Calling get-query manually works.
(om/get-query (om/class-&gt;any reconciler fskl.ios.core/AppRoot))
=&gt;  [{:app/budget [(:budget/by-date {:date #inst "2017-03-22"}) :date :amount]}

puppybits 2017-03-22T15:59:50.694609Z

My queries look like this:

(defui ^:once AppRoot
  static om/IQuery
  (query [this]
    (vec (om/get-query tabs/TabBar))))

(defui ^:once Budget
  static om/Ident
  (ident [this {:keys [date]}]
    [:budget/by-date date])

  static om/IQueryParams
  (params [_]
    {:active-date (t/at-midnight (t/now))})

  static om/IQuery
  (query [_]
    '[(:budget/by-date {:date ?active-date}) :date :amount]))

anmonteiro 2017-03-22T16:07:02.887684Z

@puppybits your Root component is stealing queries from the TabBar component

anmonteiro 2017-03-22T16:07:19.894987Z

so there’s no clear path between the root and the children

anmonteiro 2017-03-22T16:07:28.898861Z

that’s what the error message is telling you

2017-03-22T20:50:29.249246Z

anyone really using boot for om next development? I've managed to get things working with lein but, if I can, I'd like to figure out a workflow with om and boot. Am I just going against the current on this? Or does anyone know of any recent examples of this and a bit of hand holding on getting a good workflow set up?

anmonteiro 2017-03-22T21:06:51.587616Z

@vaedasynapse setting up Boot with Om Next is no different than setting up with CLJS in general

anmonteiro 2017-03-22T21:07:02.591047Z

can you clarify what you’re asking?