This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # admin-announcements (7)
- # beginners (37)
- # boot (36)
- # cider (8)
- # cljs-dev (16)
- # clojure (155)
- # clojure-hamburg (1)
- # clojure-russia (2)
- # clojurecup (21)
- # clojurescript (69)
- # clojurex (12)
- # core-async (2)
- # datavis (3)
- # datomic (5)
- # devcards (4)
- # events (2)
- # hoplon (15)
- # lein-figwheel (45)
- # off-topic (22)
- # om (77)
- # re-frame (8)
- # reagent (7)
- # slack-help (1)
I might be way off on this but I think this is an example of how routing could be done https://gist.github.com/anthgur/2cddf81e04ea78f372c6
Does anybody thought how to create independent components (think library of UI controls for example) - query nicely encapsulates reads (like components needs
:title and doesn’t care how to get it) but I’m a bit stuck with state changes. Possible way could be that the component will provide a mutation function which user can call from the own
@artemyarulin: If you mean a library of UI controls, I'd say components are stateless so they don't need to implement
but I guess it’s not all the time possible, sometimes component would benefit from the state. Actually my question is more general - I can create general
read function which just returns keys (especially using ident) and cover most of the cases. But with
mutate I have to specify quite a lot. I often found myself editing components - then mutate function, then component again, then mutate and so on
would be cool if I would find a way how to encapsulate component mutate function inside the component itself
Let me give you an example, since you mentioned a
:title prop. Your (generic) title component would implement whatever styles and behavior you'd need and render
om/children. You'd simply need to pass an element to this generic component, but the
:title prop would be queried in your stateful component. Is this clear?
If you introduce a query then you're tying them to an application state which doesn't make them generic anymore
Well :title it’s a bad example. Imagine textbox which has to maintain the internal state (like number of characters and who knows what). Update the state using events on_change on_number_of_characters changes is not a choice
with local state communication between components would be implemented using events (computed props) like on-number-of-character-changed = #(fn…) My original intention was to make communication using state and state observing.
@dnolen: Is there any reason why this here https://github.com/omcljs/om/blob/master/src/main/om/next.cljs#L955 assertion message says must be “ref or keyword”, but the condition is only
(if (keyword? k))? I’m getting an error when the remote returns a map with an ident as a key.
No, this is the initial query: Find post with this id, and grabs these attrs (as defined by sub-components)
It looks like the same thing, even when I hard-code the
om/Ident of the top-level component.
there’s really no reason to throw an error here vs. just returning the empty set if nothing is found
but of course in the case where you haven’t rendered them yet, this is not going to work
I’ve put my tutorial in progress up live on github pages. Lots to do still, but if you’re just wanting to play with query simulations and other live bits, it works well: http://awkay.github.io/om-tutorial The section on queries is where @hmadelaine added in a nice edn editor for me, as mentioned here the other day.
It is a long way from done…people were asking questions about bits that are there, and I wanted to just be able to link them. In particular, the section on queries is helpful for that.
fine with a tweet…don’t have plans for a big announce as such…just need to note that it is vey much not done.
Also, it is meant to be run locally (so you can edit the real source of the tutorial), so linking to the github project might be appropriate.
@tony.kay: still very cool stuff, I’m sure many people will find it useful even in it’s current form
Thanks, and I agree. That is why I mentioned it. I had gotten a question on my youtube overview about queries, so I just wanted to be able to point them at a link where they could play.
@tony.kay: awesome work; I'm sure this will be very useful for a lot of people. myself included. going to read through all of it
@tony.kay thanks for sharing, this is quality stuff and is really helping me study and solidify om next concepts. working smoothly, mobile and offline, as i tear through the interactive examples on my mobile riding the subway.
I guess I’ve heard somewhere that using closures in the
transact! calls is not a safe thing. Is it? Or I remember it wrong?
@dnolen: I do not…I am disturbingly unreachable in the world. don’t even carry a cell, nor do I have a home phone. Computer off? stone age @anmonteiro: @env Thanks for the feedback. Glad to know it is working on mobile. I’m reworking a lot of it, and more exercises are coming…
@artemyarulin: transact takes data…I guess you could technically pass a lamda as a parameter. The unsafe thing is to do side-effect things in your mutation functions outside of the action thunk
because you are not supposed to know if it is a remote mutation, and if it were…well, code isn’t very serializable
@tony.kay I’m a beginner, going through your tutorial now, it’s very helpful and well-organized. Thanks!
Here's a demo of the Components, Identity & Normalization tutorial that has two sections, one with the default map db, and one with a Datascript db: https://github.com/thos37/om-experiments/tree/refs
I looked at om.next about a month ago; it seems to have changed substantially since. Any recommended reading/projects if I want to use it with Datomic, DataScript, and streaming server updates (tx datoms pushed via Sente)?
@domkm that's the architecture I'm aiming for as well, but I'm unaware of any working end-to-end example for it.
@domkm: nothing om.next specific other than little client-only examples like the one I posted above or the datascript integration tutorial. https://github.com/datodev/dato is very interesting. tonsky has some good examples for streaming datoms like https://github.com/tonsky/datascript-transit http://tonsky.me/blog/datascript-chat/ http://tonsky.me/blog/acha-acha/ Those use other react wrappers, so would need to be adapted to om.next