Fork me on GitHub
#om
<
2015-12-03
>
simonb00:12:19

Anyone have any thoughts on why a Om Next app would enter an infinite read/render loop? Using DataScript. Thanks.

noonian00:12:18

Not sure, but if you have a read impl that always tries to remote you could get something like that , read, remote, merge, read, remote etc.

jgdavey00:12:44

In om.next, what’s the idiomatic way to specify both the query and a filter? In the AnimalList example with a start and end, how would you specify a query in addition?

jgdavey00:12:20

In a map as above?

simonb01:12:24

@noonian: No remotes. Everything is local on the client.

simonb01:12:55

Is there any info in the env (for example) that has a pointer as to why a read was called?

noonian01:12:29

Is your parser recursive? maybe you missed a base case?

simonb01:12:21

@noonian: yes recursive. What do you mean by base case? Thanks.

noonian01:12:58

I mean, if your parser is recursive and you have a bug, then the recursion could be causing the infinite loop

simonb01:12:45

@noonian: Ah. Yes. Could be. Hmmm. I need to look at the logs again. Thanks.

Tim01:12:37

are you allowed to refer to state like this ?

(init-state [_]
    {:info         (chan)
     :publisher    (chan)
     :publication  (:publisher #(:topic %))})

Tim01:12:35

I’m trying to do this but it doesn’t work (init-state [_] {:info (chan) :publisher (chan) :publication (pub (om/get-state owner :publisher) #(:topic %))})

Tim01:12:55

I get Uncaught TypeError: Cannot read property 'om_pending_state' of null(anonymous function) @

wilkerlucio02:12:48

@tmtwd: what are you trying to do with those channels on state? if you wanna get a message out, I believe placing then on shared and calling from the parser mutations would be more recommendable

noonian02:12:41

@tmtwd: I think you got that error because you are trying to get the state of the component before the state has been initialized since that is the function that initialize it

artemyarulin07:12:54

Hi everyone. I’m a bit lost about optimistic updates - I know how to do it (change local state and send remote command at the same time), but what if remote command failed? Does Om can help in this case somehow? I cannot simply go back in the history as during remote command user could change something else

artemyarulin07:12:46

Maybe somebody have an example? Things I saw doesn’t have error handling unfortunately

artemyarulin07:12:12

Actually the more I think about it the more I realise that I have to handle those errors manually as there could be different business logic for each case. No general solution could be created I guess… but I will be happy if somebody can point me to the right direction, thanks!

griffio07:12:14

@artemyarulin: Did you see this issue https://github.com/omcljs/om/issues/486. Is that the sort of functionality you are looking for?

artemyarulin07:12:24

@griffio: well… kinda not. This is just a way how to pass errors to the user (actually I don’t understand why state is bad for such thing) and my question is more about what to do with already changed state

griffio07:12:46

@artemyarulin: Yes, I see. The optimistic state is temporary until confirmed by the server.

griffio07:12:26

@artemyarulin: An example I found is from https://optimizely.github.io/nuclear-js/docs/06-async-actions-and-optimistic-updates.html. NuclearJs which is similar to om.next. You can see that the shopping cart data is temporary until successfully commited.

artemyarulin07:12:35

@griffio: Ah I see, basically they have a pending abstraction… hm… this may work. I guess I should check how other frameworks solves this problem. Thank you, I guess I found a right direction

danielstockton09:12:21

@artemyarulin: Errors are transient in that they usually come from bad user input which is already in the state.

danielstockton09:12:49

So I suppose you don't want them adding noise to the app state if you want to time travel back and forward, the error will appear anyway once you travel back to an erroneous state

artemyarulin09:12:13

oh, makes sense. I’m now putting everything to the app state, but I completely forgot about time-travel and undo. I should think about it

danielstockton09:12:35

You should be able to take the state, copy it to another user, and get back the same UI...You don't need the actual error for that, it will appear naturally from the state

danielstockton09:12:55

Errors are sort of side-effects of the state

artemyarulin09:12:23

Well my issue is a bit different currently. In general optimistic UI changes the local state without confirmation from the server side. What if user made a set of cchanges already and during syncronization server replied with error on first event? What could be done?

artemyarulin09:12:04

I guess it has nothing related to the om. At least for me it looks like more general issue

danielstockton09:12:02

Whatever state triggered the error, whether locally or remotely, should trigger the same error each time it is 'loaded' without the error itself being in the state

artemyarulin09:12:35

well, it could be that backend was down for a while - next time if I apply the same state it will work just fine

danielstockton09:12:06

Could be, I suppose it depends if you want to keep that in the history

danielstockton09:12:31

It's your choice whether it goes in app state or not

artemyarulin09:12:26

I know, I know. I was hoping that maybe there are some general patterns for such problems exists

artemyarulin09:12:47

but it looks like a lot of things depends on app

artemyarulin09:12:01

on requirements I mean

tony.kay14:12:43

@hmadelaine: Dude, that would be awesome

tony.kay14:12:47

send it on!

tony.kay14:12:31

@dnolen: the more I build with this, the more giddy I'm getting...not enough hours in the day. I'm so excited about building out the tutorial, but also have to get work work done...fortunately both get to use Om!

tony.kay14:12:03

@hmadelaine: One request if you integrate parinfer: a toggle switch to turn it on/off and a link to what it is so ppl know it is "doing stuff for them" instead of "doing crap to them"

hmadelaine15:12:37

@tony.kay: Ok, I am going to clean as much as possible before submitting the PR. I have to dig a little deeper for Parinfer

hmadelaine15:12:13

@dnolen: thanks, OmNext deserves the best tool to learn. @tony.kay keep up the good work !

txus15:12:03

this is awesome and SO useful

gabe15:12:07

@dnolen: that tweet’s gonna blow the team's user limit 😉

jamiei16:12:19

@hmadelaine: Wow, that looks amazingly helpful!

hmadelaine16:12:29

@jamiei thanks but @tony.kay did the hard work. I am just standing on his shoulders

jethroksy16:12:05

@tony.kay: just submitted a PR adding some explanation, let me know what you think!

tony.kay17:12:53

@jethroksy: busy morning. will look soon. Thanks!

tomc18:12:31

@tony.kay, you just made my day with this tutorial. Thanks a lot!

tony.kay18:12:39

welcome...more coming soon...just have to find the time

gtrak19:12:20

I've introduced react.js into a nontrivial living ember.js codebase, which makes seeing this especially awesome. I hope all clojurists are cheering, if they ever heard about it the horror of Object.observable: https://twitter.com/jdalton/status/661254992502747136

dnolen19:12:17

@gtrak: yeah I saw that a while back

dnolen19:12:56

it wouldn’t have affected ClojureScript programmers much anyhow but it’s good that JS isn’t introducing bad idea #931

twillis19:12:51

i thought we were up to #981 😉

gtrak19:12:19

your observer isn't syncing right, add another.

dnolen20:12:18

if you need any more evidence that Om Next is fixing some big conceptual problems around Flux / Redux / etc. simple_smile

tony.kay21:12:00

I'm not needing any more evidence of anything. The more we grok Om next, the simpler everything is getting. Just finished refactoring our production-app-in-progress. Read code down to like 6 lines. Remoting 6 lines. Mutations 20 lines. We haven't added many features yet (e.g. nothing needing params on query elements)...but the sheer lack of...well...almost every kind of pain is just awesome.

tony.kay21:12:28

the pain is understanding the higher level concepts...which is the right kind of pain

johanatan21:12:30

What's the easiest way to get a quick Om app up and running with ClojureScript on both the server (i.e., node) and the client?

johanatan21:12:45

Following this but it doesn't seem to have a server: https://github.com/omcljs/om/wiki/Basic-Tutorial

johanatan21:12:00

i.e., Is there a template for this?

noonian21:12:17

I don’t think theres a template for Om.next, since it’s moving pretty fast. Om now doesn’t have a server component, but there are some templates around. A super minimal one would be pass the —om flag to the figwheel template.

Tim21:12:31

I like chestnut, but it is for om.now right?

noonian21:12:05

yeah, I don’t think there is an om next template but there are some example projects out there

noonian21:12:14

although most are probably slightly out of date in one way or another

noonian21:12:14

I’d use a figwheel template and add in om next from the tutorials

Tim22:12:15

also one of my chestut projects live-reloading doesn’t work so I have to refresh the page

plexus22:12:22

@tmtwd what version of chestnut is it based on? Would you mind filing an issue?

Tim22:12:58

okay later tonight

Tim22:12:49

@plexus: on github?

plexus22:12:13

I plan to update chestnut, it can be simplified a lot now that Figwheel is more mature, but might be January before I can do a proper release

plexus22:12:30

@tmtwd yes on github

plexus22:12:00

So right now the Figwheel template is probably the best starting point

Tim22:12:05

yeah, I find chestnut helpful

Tim22:12:12

oh really?

Tim22:12:21

I’ll switch to figwheel

Tim22:12:51

ok added the issue

plexus22:12:33

Well it depends, Figwheel won't do everything that chestnut does, but currently I think it better reflects the state of the art

Tim22:12:00

interesting

johanatan22:12:03

The figwheel template will generate client/server app?

Tim22:12:09

is there an om profile for figwheel?

noonian22:12:15

no, just a client setup

noonian22:12:25

there is, but it is extremely minimal

johanatan22:12:32

What's the best option for client/server?

noonian22:12:20

I think its hard to recommend a server setup because Om next really doesn’t care how your server is setup.

noonian22:12:08

so any Clojure server should be easy to integrate with Om next

Tim22:12:04

on this project live-reloading works fine https://github.com/tmtwd/tic-tac-toe

Tim22:12:10

kinda confusing

johanatan22:12:54

@noonian: so, you're suggesting two separate Clojure projects?

johanatan22:12:02

Rather than having them integrated into one

noonian22:12:24

no, I would probably have separate sub-directories of src

noonian22:12:23

similar to as in @tony.kay's Om.next tutorial https://github.com/awkay/om-tutorial That way you also have a place to put devcards src and anything else you need

noonian22:12:13

Thats what I’m doing right now, and one of those is for code thats shared between the frontend and the backend. I’m only sharing the frontend routes right now.

jgdavey22:12:09

In om.next, what’s the idiomatic way to specify both the query and a filter? In the AnimalList example with a start and end, the read function grabs the subvec directly. Is there a way to communicate the query to use in that situation?

dnolen22:12:03

there’s no such things as “filters"

dnolen22:12:07

just queries

dnolen22:12:45

but you can use parameters and interpret those if you want to customize the query in some way - same as you do w/ URL query params

jgdavey22:12:21

Maybe I’m missing the syntax for providing a query with parameters

dnolen22:12:23

@jgdavey: look at om.next.impl.parser ns for the full grammar

dnolen22:12:30

the simplest case is

dnolen22:12:41

[(:user/image {:size :small})]

dnolen22:12:28

note that :start and :end from the tutorial have no special meaning at all

dnolen22:12:40

you can supply whatever you want

jgdavey23:12:29

In my case, what I’m wanting to do is like: [(:post {:post/id 123} [:post/title :post/body])]

dnolen23:12:04

right the grammar shows you how to write that

dnolen23:12:08

so that’s not valid

dnolen23:12:25

[{[:post/by-id 123] [:post/title :post/body]}] is

jgdavey23:12:46

I see! Use idents!

jgdavey23:12:07

Thanks for the help!