Fork me on GitHub
#om
<
2016-01-10
>
andrewboltachev00:01:19

UPD: Downgrading om version to one om-sync uses solved the problem

dnolen00:01:31

@octo221: lazy seqs can be in the app state provided they aren’t a part of the query structure (joins etc.)

jasonjckn00:01:42

i'm getting up to speed on the clojurescript & surrounding ecosystem. I would to prototype a webapp that is kept up to date in real-time as new events come in that are stored in a datomic database (flexible here) , any suggestions on what route to take for this that's simple/reliable/etc, which framework (reagent, om next, etc), which database if not datomic, presumbly using websockets to stream updates (?)

jasonjckn00:01:35

so far i've been reading/playing with reagent which seems fairly straight forward, and om next which i somewhat understand now

jasonjckn00:01:34

i would like to put it into production if the prototype is well received, so reliability is important

andrewboltachev00:01:45

@jasonjckn: If you want, like you said, educate yourself, so I highly recommend to start from https://github.com/omcljs/om/wiki/Basic-Tutorial on Om. Trying to learn Om Next before Om isn't likely possible (I tried to do so).

jasonjckn00:01:08

thanks andrew, i've been through all the om next tutorials now

jasonjckn00:01:19

i did go straight to om next, for better or for worse

dnolen00:01:24

@jasonjckn: I think the question is whether you’re OK with just rolling your solutions over Reagent or piggieback on Om Next patterns

jasonjckn00:01:45

dnolen: suggested something along the lines of using merge! in om next to merge in novelty that is streamed over the websocket

dnolen01:01:49

I think also a question of whether it’s just you or several other people on the project

jasonjckn01:01:49

dnolen: sorry didn't quite follow, if I'm okay with using om next design patterns but using reagent?

dnolen01:01:05

fwiw I prefer established patterns for important parts of app

dnolen01:01:15

if I don’t have to hand roll it - all the better

jasonjckn01:01:43

well, as far as team dynamics, om next probably won't work with the team, as they don't even know clojurescript besides 1 guy

dnolen01:01:51

@jasonjckn: yes - just use the same patterns with reagent

dnolen01:01:01

right so that’s probably a problem

jasonjckn01:01:11

but i'm still curious about how om next will simplify anything

jasonjckn01:01:16

yah it definitely is

dnolen01:01:26

Om Next does kind of assume you’re already pretty comfortable with Clojure(Script)

jasonjckn01:01:35

reagent seems better suited for the team that has a react/javascript background

dnolen01:01:51

I would not argue with that assessment at all

jasonjckn01:01:56

yah thinking

jasonjckn01:01:16

does om next simplify the real-time part, anything I can borrow from it?

jasonjckn01:01:30

whether it's merge or clojure.core/merge that i can do with reagent

dnolen01:01:35

it only simplifies it insofar as the real-time and request/response model is exactly the same

dnolen01:01:40

there’s no difference

dnolen01:01:26

normal Om Next apps use merge! too - the whole thing is intentionally dog-fooded on itself

jasonjckn01:01:36

with datomic you need to do some extra work to get the subscription of events to look like your datomic query results right?

jasonjckn01:01:41

there's no pull syntax for a real-time stream

dnolen01:01:56

you can call pull on entities

jasonjckn01:01:18

thanks david!

andrewboltachev01:01:54

@jasonjckn: You might also try Hoplon framework (find the corresponding channel and "Web programming with Hoplon" Clojure/conj video). It's one alternative for React-based family of CLJS frameworks (I'm currently switching to Om though). It doesn't handle real-time too, but it's update model is somewhat interesting — each transaction just updates state of the whole page.

jasonjckn01:01:46

thanks andrew, I did look at that briefly, the api looked not so different from reagent (cell vs atom), although I understand they're built on different stacks

andrewboltachev01:01:18

Is om-sync actual? I'm trying to go through this section of the tutorial https://github.com/omcljs/om/wiki/Intermediate-Tutorial#modularity but adding [om-sync "0.1.1"] seems to provide problems, e.g. this: http://dpaste.com/23YFZZ9 (this is together with om version 0.8.8). When I switch Om to 0.5.0, lein figwheel compiles but then I got "React not found" (not literally, but the sense is this) in my browser console.

andrewboltachev01:01:54

@jasonjckn: If you completed the tutorials, haven't you had problems like mine above? simple_smile

jasonjckn01:01:19

i completed the omnext tutorials 😉

jasonjckn01:01:25

haven't looked at om

andrewboltachev01:01:39

ah, and only that ones. got it!

bbss02:01:45

@iwankaramazow: I see, my project has very static data. So haven't run into those problems. Netflix apps seem pretty static too, so that might explain why they use it, doesn't go much further than -user favorites thing- (on the front-end anyway).

geraldodev11:01:50

@andrewboltachev: That om-sync thing is for old om.

nano11:01:56

@tomc: Hey, I stumbled across your route example gist and trying to add it to my app. The child query seems to execute correctly, but in my case the matching read will return {:remote true} to indicate that data should be fetched, however the :send function of the reconciler isn't being executed as a consequence, and thus the target components render function is called without the data it needs. Any ideas? I'll see if I can whip up a minimal test for you.

nano11:01:05

@tomc: If I add the target component directly via add-root, its query is being executed correctly, with the following :send's data fetching before render.

anmonteiro13:01:28

@dnolen: I'd love to see defui support react's displayName. Willing to accept a patch that adds this?

anmonteiro15:01:01

@dnolen: cool! submitting later today

bplatz17:01:38

@jasonjckn: if you include db/id with all joins in a pull, and you have set up the db.type/ref on the datascript side you can transact the pulls directly. You still need to do your subscription logic but that will take care of the db part without extra work.

andrewboltachev19:01:05

In Om Next, would implementation of tabs-like thing (i.e. few components, from which only one is currently visible) be trivial? Might I easily implement sth like "postponed query" (i.e. fetch only on display)? Would I need to fetch data for all tabs anyway?

rafd19:01:28

@andrewboltachev: i've done something like that by having the tab as a queryParam on the component, then passing it to the relevant queries, the readers then check if the param is equal to what we want and return {:remote true} if the data is not there

rafd19:01:55

it's how i have an entire site set-up with routing

nano19:01:55

@rafd do you have that on github?

nano19:01:29

@rafd i've been trying that but the child components remote fetching doesnt run, it does run if it's added as root though.

nano19:01:24

The read of the child components ends up inte :remote case though, just that the :send doesnt happen.

nano19:01:59

Gah, swedish autocorrect. hytter me näven

andrewboltachev19:01:29

@nano: I can imagine that child components must depend on key you use (sth like :app/route) to react on it's change?

andrewboltachev19:01:45

@nano: Do you have this on GitHub as well? simple_smile

nano19:01:21

No not yet, it's a battle field right now, trying to get this working. Should clean it up and push even if it's slightly broken.

andrewboltachev19:01:41

i.e. add :app/route to your (query [_] ...)

nano19:01:32

I followed this example here, https://gist.github.com/tomconnors/c1cceaae84fd059e37a3, and my child component's query is: '[({:grid-items ?item} {:section ?section :view ?view})]) do you mean just prepending :session/route there to the outer list?

andrewboltachev19:01:44

@nano: let me check the gist

rafd19:01:09

@andrewboltachev: i currently have all the params in my root view

nano19:01:39

Will github this as soon as I get routing working, after that it should be mostly downhill. Working on a Swedish Television Tizen app for my new Samsung TV.

andrewboltachev19:01:29

thanks @rafd ! I certainly like this more than huge gist from above

nano19:01:57

@rafd: So you just perform all queries all the time?

nano19:01:01

or are they lazy until accessed? haven't investigated.

rafd19:01:31

the queries check that parameters are the right ones, otherwise just return empty

rafd19:01:44

...but, I'm not sure if they are triggered every time

rafd19:01:11

i'll investigate now

rafd19:01:31

@andrewboltachev: note, i am using datascript for storing data + secretary for routing

rafd19:01:02

but you should be able to adapt

rafd19:01:15

also, not sure if this is the 'right way' to do it, but it WorksForMe™

rafd19:01:41

i think david is waiting to see if what exists now in om.next is sufficient for routing

andrewboltachev20:01:21

I wonder... if om/set-query! is aware of reconciler (and none of the code from inside components it) as in this example https://github.com/omcljs/om/wiki/Quick-Start-(om.next)#change-the-query , where should I put it? Inside :action of mutatef or somewhere else?

sander23:01:37

@rafd in your defroute you use om/class->any which is named a 'development time helper' in the docs. do you think using om/app-root would be better in this case?