om

Please ask the channel first, not @dnolen directly!
peeja 2017-04-23T17:17:39.167234Z

Is there a good way to get the reconciler to queue a send of the entire root query to a particular remote every time the state changes?

peeja 2017-04-23T17:18:01.168448Z

(I'm still trying to work out a good way to implement live queries.)

petterik 2017-04-23T17:28:52.206118Z

@peeja Everytime the state changes on the client or on the server? On the client, could you use TxListen? On the server, I push some change notifications of a read that's changed along with datomic's basis-t. Using basis-t (or something similiar) I can avoid sending requests I've already read data for when there are frequent updates. I use (om/transform-reads reconciler [:key-to-read]) to queue the reads locally and remotely. Lastly, to find all reads for a specific remote, could you maybe call (and memoize) (keys (parser env (om/query (om/app-root reconciler)) remote))?

peeja 2017-04-23T17:30:13.210806Z

On the client. :tx-listen might do it…

peeja 2017-04-23T17:30:57.213617Z

Maybe the parser already runs as I need it?

peeja 2017-04-23T17:31:19.214905Z

I tried swap!ing the state and didn't see it, but perhaps transact! will always do what I need

peeja 2017-04-23T17:31:25.215264Z

and that's what I'd be using in real life anyhow

peeja 2017-04-23T17:32:02.217415Z

Oh, no, transact! will only read what I tell it to read…

petterik 2017-04-23T17:33:03.220931Z

Yeah. Firing off another transact! in :tx-listen depending on what was transacted or what's being transacted maybe?

peeja 2017-04-23T17:33:15.221513Z

Doesn't that recurse infinitely?

peeja 2017-04-23T17:33:59.224417Z

I guess it feels like I'm doing extra work to undo things that Om's doing "for me".

petterik 2017-04-23T17:34:00.224477Z

Depends on how you examine what is being and what was transacted

petterik 2017-04-23T17:34:12.225127Z

hmm

peeja 2017-04-23T17:34:17.225393Z

I don't want to transform-reads a specific set of keys, I want the whole query

peeja 2017-04-23T17:34:26.225962Z

(as processed by the parser for the given remote)

peeja 2017-04-23T17:35:12.228640Z

My plan is to have something stateful stay informed of changes to the query, and adjust the live data it listens for appropriately

peeja 2017-04-23T17:35:38.230081Z

which means it always needs a new copy of entire root query any time it (may) change, to run a diff

petterik 2017-04-23T17:37:04.235032Z

What if you put this stateful thing in :shared and call it either from your root component everytime it updates, or via :tx-listen depending on what you need

peeja 2017-04-23T17:37:32.236654Z

I feel like the components shouldn't know this thing exists

peeja 2017-04-23T17:37:45.237306Z

:tx-listen may work

peeja 2017-04-23T17:38:14.238942Z

How do I transact! to read the entire root query from a remote?

petterik 2017-04-23T17:39:54.244910Z

I don't think you can do it out of the box, but I can think of two ways of doing it

petterik 2017-04-23T17:40:07.245577Z

1. call the parser, then call transact! with some result

peeja 2017-04-23T17:40:40.247602Z

How would I "call the parser" other than through transact!?

petterik 2017-04-23T17:41:23.250436Z

2 (the way I'm doing it), wrap your parser in a function which looks for a dynamic var, for example *allowed-remotes*, and returns nil if the env's :target is not in *allowed-remotes*. Binding it using binding

petterik 2017-04-23T17:41:49.251910Z

You'd get the parser from (:parser (:config reconciler))

petterik 2017-04-23T17:42:04.252835Z

and call (#'om/to-env reconciler)

petterik 2017-04-23T17:42:08.252999Z

to get env

peeja 2017-04-23T17:42:13.253273Z

Ew… πŸ™‚

petterik 2017-04-23T17:42:16.253421Z

πŸ™‚

petterik 2017-04-23T17:42:29.254310Z

Solution to all om.next problems is another parser middleware

peeja 2017-04-23T17:42:50.255453Z

I've got middleware out the wazoo as it is, but it's not fixing this one yet πŸ™‚

peeja 2017-04-23T17:43:35.258120Z

How does *allowed-remotes* help?

peeja 2017-04-23T17:44:10.260230Z

I believe I'm not getting the parser call I want in the first place

petterik 2017-04-23T17:45:01.263260Z

(binding [*allowed-remotes* #{:the-remote-you-want}] (om/transact! reconciler (om/get-query (om/app-root reconciler)))) would get the full query with only the remote you want

petterik 2017-04-23T17:45:08.263706Z

no?

peeja 2017-04-23T17:45:46.266091Z

Oh, I see. Sure, that'll work.

πŸ‘ 1
petterik 2017-04-23T17:47:22.271769Z

Oh sorry, I apparently left that bit out

peeja 2017-04-23T17:47:48.273266Z

Can I accomplish the same thing by forceing the remote? I'm not entirely clear on what that does.

petterik 2017-04-23T17:48:06.274248Z

I don't know. Maybe. I'm not clear either of how to use it

petterik 2017-04-23T17:48:12.274537Z

I've never used it

peeja 2017-04-23T17:57:27.307842Z

Yeah, I can't get that to do anything useful. Oh well. *allowed-remotes* may be what I'm stuck with, as hacky as it is. πŸ™‚

peeja 2017-04-23T17:57:31.308014Z

Thanks for the help!

πŸ‘ 1