What is the idiomatic way of coming up with idents for components that are only ever on the dom tree once?
I’m currently using [:child/by-id “ComponentName”]
@berkeleytrue iirc :singleton
is a pattern ive seen throughout cookbooks and tests
not sure you’d use :thing/by-id
with that though
as its not really an id...
I would want to get away from /by-id
So would the ident be something like [:main :singleton]?
Is there a reference somewhere for the parser that has a legend of these keywords?
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..
@danielstockton I’m guessing you are talking out delaying the on-tarted-callback
reads? If that’s the case, you can make a transaction out of those reads, and call that transaction after your auth process.
im actually not using untangled, but i was hoping some patterns may have developed here that i could borrow
@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.
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
well, it is defined, but it is defined by essentially hooks that you can plug into
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)
UI events…should be obvious what you do there: run transact!
setTimeout…again: keep hold of the reconciler (which in Untangled is in the app), and use transact!
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"
@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.
@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
@mitchelkuijpers tried that, i don't think its all hooked up yet
i don't see the :target being added to the ast
@danielstockton In Om Next quoting is used to mark AST with remote
Oh I am pretty sure that works, did you add a ~
?
e.g. [‘:thing]
implies you want a remote read
there is a helper function as well that let’s you say which remote
then you implement that in the parser.
in Untangled, we have all of that pre-coded so the loading story is clear…no parser emitting code required
(om/transact! component
`[(user/login {:username ~username :password ~password}) ~(om/force :totals :api)])
that’s unquoting
ah yes, force
That’s the helper
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
this is definitely more of an #om discussion…all of these complications aren’t necessary with Untangled
Yeah, I had no luck there earlier, but I'll try again.
we’re just going to tell you to use Untangled 😉
soooo much easier, with pretty much all of the benefits
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.
Yep. I’ll look forward to PRs dolling up Untangled internals in a few months 🙂
Is untangled opinionated about the server-side? I'm dealing with a django application on the backend.
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.
you hitting REST APIs?
seems like you lose a lot of the benefits if you don’t at least have a core API endpoint in Clojure
no, i actually wanted to write a parser for the om query syntax and have a single endpoint, with a few exceptions
yeah, Untangled has you do exactly that
you have to provide an Om parser
but it handles the network plumbing API endpoint
i managed to get some way in python using python-transit
I'll have to look into it
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
as long as you’re using transit
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
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
Ok, i'll keep an eye out, I definitely need to dig into untangled more