Fork me on GitHub
#om
<
2016-11-01
>
arohner00:11:24

is it ok to om/transact! during a (defmethod mutate…)?

hlolli07:11:33

@arohner maybe, but it more ok just to swap!, should give you the same end result, Im pretty sure you will hit a problem in the long run doing recursive transactions.

tomjack08:11:49

How do you do your (dom/label #js {:htmlFor ?})

fenton11:11:39

thought query should be [:me-mail] not [{:me-mail '[*]}] for a simple property?

anmonteiro11:11:02

@fenton you need to clarify what your problem is

anmonteiro11:11:12

what did you expect to see (and where) vs. what you're seeing

anmonteiro11:11:08

this works:

cljs.user=> (om/db->tree [:me-mail] @my-state @my-state)
{:me-mail ""}

arohner20:11:03

Is {:value [:foo]} in a (defmethod mutate) supposed to work? Everything behaves fine when I (om/transact c [(foo) :foo]), but doesn’t work when I (om/transact c [(foo)]), with {:value [:foo]} in the defmethod

arohner20:11:22

i.e. the page doesn’t re-render based on :foo changing

anmonteiro20:11:07

(spoilers: it doesn't mean absolutely nothing 🙂 )

arohner20:11:41

I’m really confused at what it should do then

arohner20:11:12

also, it seems like a nice feature to have, so the “api” around what should happen when you (transact [(foo)]) is more encapsulated

arohner20:11:14

needing to specify (transact [(foo) :foo]) everywhere in your app seems like an opportunity for bugs

anmonteiro20:11:54

@arohner you can always wrap your transact! calls with your own function

arohner20:11:24

so what does {:value {:keys []}} do then?

arohner20:11:17

should it be removed from the docstring of om/parser then?

anmonteiro20:11:10

I don't see why

anmonteiro20:11:18

I think the docstring is consistent with the behavior

arohner20:11:29

what behavior? you just said it does nothing?

anmonteiro20:11:36

:value is an optional hint at keys affected by the mutation; it has no effect on rerendering

anmonteiro20:11:56

behavior, or lack of thereof

arohner20:11:32

FWIW, I’ve found the docs for om.next to be incredibly frustrating, more so than om now. I’d be happy to help improve them, but I don’t know enough about how it works yet.

anmonteiro20:11:53

yeah, they're lacking a bunch of things

anmonteiro20:11:26

Hopefully we'll be able to put together a website soon enough, with good documentation

peeja21:11:49

@anmonteiro I've always been confused by that too: hint to whom? Is there a way that my own code should/could be reading the :keys value coming out of the parser and reacting to it?

anmonteiro21:11:19

@peeja yeah I think you can use the return value of transact!

anmonteiro21:11:38

for remote stuff you'll have :keys in the merge's res

peeja21:11:38

I mean, I see that it's there, but is there anything useful to do with it?

peeja21:11:51

Oh, that's interesting

anmonteiro21:11:55

you can queue them for re-rendering

anmonteiro21:11:07

you can call another transact! too with those keys

anmonteiro21:11:22

e.g. (transact! this [:foo :bar])

anmonteiro21:11:41

transacts don't necessarily need to have a mutation 🙂

peeja21:11:07

Oh, yeah, neat

anmonteiro21:11:35

@peeja btw have you checked out the new Compassus release?

anmonteiro21:11:43

seems to have all the stuff you were asking for 🙂

peeja21:11:51

@anmonteiro: Ooh lovely! Will do!

anmonteiro21:11:15

check out the changelog for breaking changes

anmonteiro21:11:35

everything's written down there, should be easy enough to upgrade

mss21:11:45

serious newbie question, but assuming I have a bunch of factory functions for my defui created components, is there an easier way to render a hierarchy them dynamically than passing invocations of the factory functions as children?

mss21:11:23

i.e. right now I have something like (component-a {:children (component-b {:children (component-c {:some-prop 123})

mss21:11:49

although what’s happening is intuitive, it feels a little unwieldy

anmonteiro21:11:49

@mss hrm normally the way I render children is:

(component-a nil
  (component-b nil
    (component-c {:some-prop 123})))

mss21:11:12

ahhh I was mistaken about the signature of the factory fn

anmonteiro21:11:15

you can get a component's children through (om.next/children this)

mss21:11:54

thanks so much for the help, really appreciate it

arohner21:11:04

Ok, stupid question, that didn’t seem to be documented anywhere. if I create a component with its factory, passing nil to props, it can query from the root of the app-state?!

arohner22:11:53

hrm, this seems connected to transacting. a default read behaves as I previously expected

arohner22:11:12

but I have a component being called with no props that, after a transaction, reads as if it was querying the root

arohner22:11:56

(defui Foo static om/IQuery [:foo/bar]) (foo) (om/transact rx [(foo/bar {:value “hello”})])