Fork me on GitHub
#om
<
2015-11-28
>
dnolen00:11:07

@tony.kay: the parser thing is just a vestige I think, no one reason to drop processing like that anymore

tony.kay00:11:23

On OM-503, care to discuss? Or you just want to ponder?

dnolen00:11:05

@tony.kay: parser thing fixed in master

dnolen00:11:51

feel pretty tried post turkey day simple_smile

dnolen00:11:12

happy to chat about it early next week

tony.kay00:11:13

oh cool...it is written down simple_smile Relax

Oliver George00:11:09

OM remotes introduce novelty via a callback function which is called with the data returned. Is the callback exactly equivalent to manually introducing novelty via (om/merge! reconciler data)?

Oliver George00:11:43

I'm specifically wondering ... Does the callback include required context? Does the callback control when rendering occurs? Can we reuse the callback in the case that queries are done individually? (considering a SignalR remote)

tyler01:11:15

Is merge! meant to be used in mutations?

tyler01:11:07

I’m trying to add a new item to a list and keep it normalized without having to do so manually

Oliver George01:11:36

I think you want to use transact! and a mutate fn

Oliver George01:11:11

My plan for merge! is where the server broadcasts to client to update some data.

tyler01:11:48

I was trying to use merge in the mutate function. Probably not the right thing to do. So to add an item to a normalized list would you have to update the list with the ref and add a new identity?

tyler01:11:11

I was trying to figure out if there was an om-idiomatic way to do those two things together.

Oliver George01:11:02

It'd be interesting to come up with every possible way to do that but I suggest keeping to techniques presented in the om wiki (aka swim between the flags) while you're getting a sense for what is the best solution.

tyler01:11:02

That makes sense. I’ve gone through all the tutorials and couldn’t find anything on inserting into a normalized list.

Chris O’Donnell04:11:03

Does anyone edit om components in vim? The indentation is a little wonky and I'm not sure how to fix it.

tony.kay04:11:13

@tyler: inserting into a normalized list is just: insert the ident into the list, and make sure the object is in the top-level table.

tony.kay04:11:16

and you don't want merge! in your mutation functions...merge! is for things like @olivergeorge said: merging in novelty from a side-band source like server push.

tony.kay04:11:19

there is no automatic way to merge items into a normalized list...does the new item go on the front of the list? the back? the middle? The base merge-tree function is quite naive about the whole thing and just does a non-deep top-level merge. You can plug in your own merge functions, but during a mutation you just have to make the modifications to the app state that make sense...and there are just too many possibilities to automate.

tony.kay04:11:09

@tyler: one thing you can do is take the non-normalized state-tree looking thing, and run it through tree->db. Then you'll have the bits in the right form...but for a small case like inserting a single item that seems overkill.

tyler04:11:05

yeah I tried with tree->db and eventually landed at just doing it manually

tyler04:11:27

I can see why it can’t be automated intelligently, too much variation in implementation

Oliver George07:11:16

Just looking through the autocomplete tutorial. Seems like you could factor out the core.async and the example would be simpler. Also I think the search-field should use :onChange not :onKeyUp (at least I needed it to make it work in Chrome).

Oliver George07:11:34

(also, thanks, just had a huge "OH!" moment about query->ast.)

Oliver George07:11:05

This might be the simplified send fn for that example

(defn search-fn [query cb]
  (let [gjsonp (Jsonp. (Uri. (str base-url query)))]
    (.send gjsonp nil (fn [[_ results]]
                        (cb {:search/results results})))))

(defn send [{:keys [search]} cb]
  (when search
    (search-fn (-> search om/query->ast :children first :params :query) cb)))

griffio07:11:42

@olivergeorge: I think the core async is there to handle things like debouncing and rate limiting that would be needed in a more robust auto complete. Html5 recommends “oninput" instead of onchange/keyup etc - https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/oninput

anmonteiro11:11:05

@dnolen: the typo fix is unrelated with OM-502, which is still happening

danielstockton12:11:54

@codonnell You probably have to add some clojure_fuzzy_indent_patterns to your vimrc

danielstockton12:11:22

I recently switched to using spacemacs, you get to enjoy things from the emacs world like cider without learning new key bindings

danielstockton12:11:37

Helm was really nice (autocomplete/selection narrowing), I don't like having to learn and remember a lot of things

Chris O’Donnell12:11:40

@danielstockton: Thanks. I tried that and wasn't able to get it to work quite right. And ironically, I discovered spacemacs last night after asking the question. It looks really awesome! I'm excited to explore it.

juhoteperi12:11:59

@codonnell: @danielstockton: Adding query and ident (in addition to render and other old methods) to lispwords should help: autocmd FileType clojure setlocal lispwords+=query,ident

Chris O’Donnell12:11:51

@juhoteperi: The biggest problem for me is actually the indentation of the dom functions. I often wanted to put (dom/div nil on the first line and more code on the line below. Instead of indenting 2 spaces, vim would line me up with nil.

juhoteperi12:11:19

@codonnell: You can add div and other dom elements to lispwords also. I have not done it myself as I use Sablono instead of om.dom.

sander12:11:33

just spent 15 minutes trying to find an identity bug when it turned out i confused om.next/query with om.next/get-query. how about renaming the second one to bound-query?

Chris O’Donnell12:11:39

@juhoteperi If I add elements individually to fuzzy_indent_patterns, it seems to work. I really wanted to add the whole om.dom namespace, but I think it is pattern matching on just the function name, rather than the entire dom/div expression. For now I'll give spacemacs a try, and if I don't like it I'll just functions individually.

juhoteperi12:11:52

@codonnell: Yes it only mathes against function name. It's better to use lispwords instead of fuzzy_indent_patterns when you don't need regex, it's faster to match against lispwords than against patterns.

Chris O’Donnell12:11:54

@juhoteperi: I'll do that, then. Thanks!

sander13:11:02

is there a recommended pattern for keeping a pointer to the 'selected item' in the data tree? i've got {:sections [[:section/by-id :home] [:section/by-id :contact]]} and want to be able to render and mutate the 'currently shown' section

griffio14:11:03

@sander Did you look at https://github.com/omcljs/om/wiki/Thinking-With-Links%21 - maybe close to the recommended pattern?

sander14:11:38

thanks @griffio, read it indeed and was thinking about using that, but not sure still how

sander14:11:34

probably would have a (defui CurrentSection …) that queries for '[:current-section _], but then i'm not sure how to add joins/unions to that query

jannis14:11:04

@sander: Having {:current-section [:section-by/id :home]} in your app state would make sense. Then, query the usual way - [... {:current-section (om/get-query CurrentSection)} - and you should be set.

sander14:11:36

@jannis: cool, that's what i was hoping for and trying, it just seems that [{:current-section (om/get-query CurrentSection)}] expects the resulting :current-section val to be a vector (since the query contains a join)

jannis14:11:11

You'll need a read function that resolves the link in :current-section into the real thing, e.g. by doing something like {:value (let [st @state] (get-in st (get st :current-section)))}. (get st :current-section) retrieves the link, (get-in st [:section/by-id :home]) resolves it into the real thing.

sander14:11:21

@jannis: ah nice, i've been trying to keep my read-fn limited to something like (om/db->tree query (get st k) st) but it makes sense to extend it for this case, and i can still do db->tree on the results. thanks!

jannis14:11:53

You don't really have to go back to the tree instead of db, you can just resolve the link in the normalized app state via get-in. That's one of the benefits of normalization after all. simple_smile

jannis14:11:36

And the db still has all your data, only organized differently.

dnolen14:11:18

@sander it’s too late for me to want to change names like get-query

dnolen14:11:56

@anmonteiro: thanks for the clarification

sander14:11:17

@jannis the db->tree was for references i have within sections, e.g. the :contact section refers to various [:contact-link/by-id …] values. but good points, i notice i have to think a bit more pragmatically about data. thanks for the help!

sander14:11:39

@dnolen: understood, i'll get used to just not trying to call om/query in my code simple_smile

jannis14:11:41

@sander: Ah, right, makes sense. Good luck simple_smile

anmonteiro16:11:22

@dnolen: would you consider adding a 3-arity get-computed ([component props k-or-ks]) for the case when we want to read the next/prev-props's computed?

dnolen16:11:43

@anmonteiro: sure patch welcome if you’ve sent in a CA

anmonteiro16:11:04

Alright, could you pls send a CA then?

anmonteiro16:11:15

Pming my email

tony.kay19:11:12

@dnolen: FYI, I'm writing a new process-roots...just about done.

tony.kay19:11:22

just so we don't dupe effort

tony.kay22:11:18

@dnolen: process roots is done. There is one issue that we should resolve at some point soon, and it is explained in the PR text.

dnolen22:11:39

@tony.kay: cool will take a look later and offer feedback, thanks!