Fork me on GitHub
#untangled
<
2016-11-22
>
berkeleytrue05:11:53

What is the idiomatic way of coming up with idents for components that are only ever on the dom tree once?

berkeleytrue05:11:27

I’m currently using [:child/by-id “ComponentName”]

adambrosio05:11:43

@berkeleytrue iirc :singleton is a pattern ive seen throughout cookbooks and tests

adambrosio05:11:10

not sure you’d use :thing/by-id with that though

adambrosio05:11:16

as its not really an id...

berkeleytrue07:11:08

I would want to get away from /by-id

berkeleytrue07:11:27

So would the ident be something like [:main :singleton]?

berkeleytrue07:11:24

Is there a reference somewhere for the parser that has a legend of these keywords?

danielstockton08:11:39

This is more of an om.next question but I figure more people here have experience writing real applications. Does anyone know of any patterns for forcing a remote read or delaying a read until after an event? My specific use case is that I have a mutate that logs a user in and acquires a JWT token and I need to delay or re-run some requests after receiving that token in order to authenticate..

mahinshaw16:11:15

@danielstockton I’m guessing you are talking out delaying the on-tarted-callbackreads? If that’s the case, you can make a transaction out of those reads, and call that transaction after your auth process.

danielstockton16:11:47

im actually not using untangled, but i was hoping some patterns may have developed here that i could borrow

tony.kay17:11:07

@danielstockton There really isn’t a pattern, as such. The thing is that Om Next in general has a specific model for how you model remote interactions. Delaying is an orthogonal concern. You could use setTimeout or something similar.

tony.kay17:11:56

If you’re talking about possibly triggering another action after a particular network request finishes, then that has a bit more to it in the Om Next model, since the return sequence in Om Next isn’t explicitly defined

tony.kay17:11:22

well, it is defined, but it is defined by essentially hooks that you can plug into

tony.kay17:11:03

The only events you have are UI events, end of processing (e.g. return from networking), and anything you make up (e.g. via setTimeout)

tony.kay17:11:18

UI events…should be obvious what you do there: run transact!

tony.kay17:11:38

setTimeout…again: keep hold of the reconciler (which in Untangled is in the app), and use transact!

tony.kay17:11:21

the network pipeline is for you to write, so you plug into that however you see fit…there is more to say about Om Next, but it is along the lines of “you plug that into the merge/migrate mechanisms"

danielstockton18:11:11

@tony.kay Is there some way to force a remote re-read? I transact and force a re-read, but it doesn't hit the remote. This is my problem.

mitchelkuijpers18:11:02

@danielstockton This is not related to untangled at all. But this might be interesting for you: https://github.com/omcljs/om/wiki/Documentation-(om.next)#force

danielstockton19:11:12

@mitchelkuijpers tried that, i don't think its all hooked up yet

danielstockton19:11:20

i don't see the :target being added to the ast

tony.kay19:11:31

@danielstockton In Om Next quoting is used to mark AST with remote

mitchelkuijpers19:11:46

Oh I am pretty sure that works, did you add a ~?

tony.kay19:11:50

e.g. [‘:thing] implies you want a remote read

tony.kay19:11:07

there is a helper function as well that let’s you say which remote

tony.kay19:11:15

then you implement that in the parser.

tony.kay19:11:02

in Untangled, we have all of that pre-coded so the loading story is clear…no parser emitting code required

danielstockton19:11:28

(om/transact! component
        `[(user/login {:username ~username :password ~password}) ~(om/force :totals :api)])

tony.kay19:11:41

that’s unquoting

tony.kay19:11:50

ah yes, force

tony.kay19:11:57

That’s the helper

danielstockton19:11:05

I can't get it to work, or at least not as expected. I'm checking the read function and expecting the ast to have :target :api

tony.kay19:11:12

this is definitely more of an #om discussion…all of these complications aren’t necessary with Untangled

danielstockton19:11:43

Yeah, I had no luck there earlier, but I'll try again.

tony.kay19:11:04

we’re just going to tell you to use Untangled 😉

tony.kay19:11:22

soooo much easier, with pretty much all of the benefits

danielstockton19:11:44

It might be, I'm probably re-implementing a lot of things it solves, but it's a good learning exercise to discover them for myself.

tony.kay19:11:12

Yep. I’ll look forward to PRs dolling up Untangled internals in a few months 🙂

danielstockton19:11:59

Is untangled opinionated about the server-side? I'm dealing with a django application on the backend.

tony.kay19:11:14

It’s easier if you use the server side. The SNAPSHOT version of server was just refactored to pull apart the bits so you can build it into your own web server.

tony.kay19:11:18

you hitting REST APIs?

tony.kay19:11:42

seems like you lose a lot of the benefits if you don’t at least have a core API endpoint in Clojure

danielstockton19:11:50

no, i actually wanted to write a parser for the om query syntax and have a single endpoint, with a few exceptions

tony.kay19:11:04

yeah, Untangled has you do exactly that

tony.kay19:11:10

you have to provide an Om parser

tony.kay19:11:22

but it handles the network plumbing API endpoint

danielstockton19:11:29

i managed to get some way in python using python-transit

danielstockton19:11:41

I'll have to look into it

tony.kay19:11:33

The primary things we handle for you on the server are catching exceptions, wrapping up tempid remaps, and a few other trivial things. Stuff you’d have to write yourself, but it’s just not a lot

tony.kay19:11:47

as long as you’re using transit

tony.kay19:11:35

We still need to write docs on our new server stuff that’s been teased apart. But yeah, if you’re using python on the server you’d have to write a query parser

adambrosio19:11:57

untangled server @ 0.7.0-SNAPSHOT has docstrings on the new untangled-system function for building a server once I have some time this week I will be porting untangled-template to use it, and adding some docs to the devguide

danielstockton19:11:31

Ok, i'll keep an eye out, I definitely need to dig into untangled more