Fork me on GitHub
#untangled
<
2016-06-29
>
jasonjckn00:06:05

is the 3 parameter version of req->response non-standard?

jasonjckn00:06:18

that might be messing with this library i'm trying to use

adambrosio03:06:43

iirc i changed it so its env and bidi’s match

adambrosio03:06:52

the request is now in the env

adambrosio03:06:00

let me check what version that happened in

adambrosio03:06:18

for earlier versions you are correct with the 3 arity version

cjmurphy03:06:35

Is there documentation on the :config-path in the Untangled Server? For instance it might be: "config/demo.edn". There's also "defaults.edn" where I am currently actually setting the port. Should I put my own application specific keywords in :config-path for instance? And how do I get at them if I do? I'm asking because the name "config/demo.edn" would seem to suggest it is configuration for the application, rather than Untangled specific configuration.

adambrosio03:06:22

defaults.edn gets deep-merge'd with :config-path where defaults.edn is overridden by :config-path

adambrosio03:06:10

you can put whatever you want in both of these files the idea is that defaults.edn contains a bare set of configuration for your app to work and not screw up your databases

cjmurphy03:06:40

So I can just leave out defaults.edn for a simple application. Okay.

adambrosio03:06:56

whereas :config-path should be the “default” path to look for a config file

adambrosio03:06:22

this can be overridden by supplying -Dconfig=/path/to/config.edn on the cmdl when running your jar

cjmurphy03:06:55

I'm just doing a tiny application to try out the server.

adambrosio03:06:12

ok then a defaults.edn with just {} will be fine

cjmurphy03:06:28

Oh okay it has to be there.

adambrosio03:06:12

yeah it does, and usually we put that in resources/config/defaults.edn

adambrosio03:06:47

as resources is in your classpath and it looks for it under config/defaults.edn using

cjmurphy03:06:24

But just simply how do I get at my own data I put into the config, or should I use my own config file for application specific stuff?

adambrosio03:06:52

where are you trying to get at the config from?

cjmurphy03:06:36

On the server, wanting to read in a file that will be used by the application. Just once for the application.

adambrosio03:06:13

hmm, if you were in a mutation or a read i would tell you to look in the env at :config

adambrosio03:06:08

okay so if you want to do this once on startup, you can use the :components key in new-untangled-server to put a stuartsierra component to read that file in

adambrosio03:06:13

let me find you an example

cjmurphy03:06:05

I think I got it - (:config env). I am wanting it from a read on the server - so that should work.

cjmurphy03:06:37

(-> env :config :my-kw)

adambrosio03:06:48

so when you say file, the config file is what you mean?

adambrosio03:06:01

its not some other arbitrary (non-edn) file?

cjmurphy03:06:11

No - an application specific file.

cjmurphy03:06:36

No - it is actually a markdown file.

adambrosio03:06:53

okay so config only understands .edn files

adambrosio03:06:02

so you would have to create a custom component to read that

cjmurphy03:06:41

I was just wanting the name of the file that's all - for the name to be in configuration.

cjmurphy03:06:13

Just an application specific String really.

adambrosio03:06:55

important parts are component/using on the config, and grab its :value

cjmurphy03:06:50

That's nice. Your getting me to do it properly with a component.

adambrosio03:06:02

im not sure you can do this only once on startup otherwise

cjmurphy03:06:59

And I going to have to set up the component dependency. Have to read up on Stuart Sierra for that.

adambrosio03:06:34

untangled-server should already depend on that, unless i missunderstood your statement

cjmurphy03:06:18

Just how to integrate MarkdownReader into the rest of the application really.

cjmurphy03:06:48

Got it thanks simple_smile

adambrosio03:06:03

to get access to it, add it to :parser-injections if you want it in your env

adambrosio03:06:53

should just make a video on this like tony has for other things

cjmurphy03:06:42

Yeah the videos are good. I also like the idea of a somewhat bigger application than usual tutorial ones. So I would just understand it completely then go to it as a reference. It would have/need additional SS components.

adambrosio03:06:42

~ 3 minutes in

adambrosio03:06:24

ive previously built untangled-template for earlier versions of untangled, but it could be a good starting place and reference

adambrosio03:06:39

i may spend some time this week updating it

cjmurphy03:06:46

Oh thanks, its already there. I s/have noticed that.

adambrosio03:06:50

all good, you had some other questions mixed in there so its fine

cjmurphy15:06:47

Yeah I didn't realise would need a component till talked to you. It all works as you outlined. Two source files affected are here: https://github.com/chrismurrph/wandering/tree/master/src/server/app

adambrosio17:06:12

looks good, something that I’ve done in my project(s) is to pass config-path to make-system and have the user.clj file pass it something local (like what you have now), and a core.clj file that is used in production that references an absolute file path (eg: /usr/local/etc/wandering.edn

currentoor17:06:57

@mahinshaw: with untangled-websockets did you every see an error like this?

16-06-29 17:17:38 Macintosh.local WARN [taoensso.sente:159] - Bad ev-msg: {:ch-recv #object[clojure.core.async.impl.channels.ManyToManyChannel...

jasonjckn17:06:17

@tony.kay: in the videos you're using vim emulation + ? for parens management

jasonjckn17:06:31

i wish dd in the vim emulation wouldn't unbalance parens

tony.kay17:06:42

cursive structural editing

jasonjckn17:06:48

paredit or parinfer?

jasonjckn17:06:55

in the video your structural editing is off 🙂

jasonjckn17:06:57

i looked at the bottom right

tony.kay17:06:09

that setting is for auto paren balancing, which I dislike

tony.kay17:06:25

Cursive has paredit commands you can map to kb shortcuts

jasonjckn17:06:33

so you have a vimrc file?

tony.kay17:06:34

I don't use dd in vim and clj...I use kill

jasonjckn17:06:35

mind sharing

jasonjckn17:06:49

oh, keyboard*

tony.kay17:06:51

I can send you my keymap file. I don't have much in vimrc

jasonjckn17:06:12

got it, nah that's fine

tony.kay17:06:32

So, I have ALT-k mapped to kill next form into copy buffer, and then I heavily use things like raise, splice, wrap, etc.

jasonjckn17:06:36

apparently the vim emulation can be modified with a vimrc but haven't looked into it, in emacs I have it so DD auto balances parens

jasonjckn17:06:49

nods cool, i'll set that up

tony.kay17:06:04

you can do things like this in idea vimrc:

tony.kay17:06:07

map >( :action :cursive.actions.paredit/barf-backwards<cr>

tony.kay17:06:15

I forget how to get the list of action names

tony.kay17:06:23

It is a : command

tony.kay17:06:38

:actionlist

mahinshaw17:06:52

@currentoor: Yes. Are you seeing that with push or with mutations/reads?

jasonjckn17:06:01

parinfer + vim emulation has some bugs in it, but if they fix it, it'll be super effective

jasonjckn17:06:12

i filed a git issue

tony.kay17:06:32

I didn't know parinfer was available...or do you mean the paren balancing built into cursive?

tony.kay17:06:52

yeah, I found it more annoying than useful

jasonjckn17:06:52

if look at the bottom right "structural off" "paredit" "parinfer"

jasonjckn17:06:59

right now it's annoying yah

jasonjckn17:06:23

in emacs I use evil-cleverparens

currentoor17:06:28

@mahinshaw: I'm seeing it with just the initial ping

tony.kay17:06:32

Oh, those are recent additions!

tony.kay17:06:51

used to just be on/off

jasonjckn18:06:13

if only it worked lol

tony.kay18:06:35

well, I've adapted to not needing/wanting it. The manual wrap/close commands make it pretty easy

tony.kay18:06:34

The "close and newline" is great for adding a form after the one you're on

mahinshaw18:06:23

@currentoor: Not really sure. I there some code I can take a look at? Minimum reproduction? I haven’t had that problem with just establishing the connection.

currentoor18:06:24

@mahinshaw: it's a bit messy right now, but out of curiosity what was the fix for you?

mahinshaw18:06:38

I think I ran into those messages when I was building the lib and sending bad messages. Essentially you can run into these issues when you are deserializing the edn/transit data. It might be worth looking at the websocket frames and seeing if they are deserialized properly

mahinshaw18:06:15

There also be malformed messages in other places, but that will be harder for me to diagnose

currentoor18:06:05

I'll look into those, thanks.

jasonjckn21:06:35

i notice sometimes when browsing to localhost:3000/dev.html it serves stale clojurescript, sometimes even when I switch to a different project with different clojurescript codebase entirely, the browser still serves the old code, like some lack of cache invalidation or something, anyone ever notice anything like this?

adambrosio21:06:38

all the time, which is why we’ve opened up the chrome inspector, gone to the network tab and checked disable cache

adambrosio21:06:22

@jasonjckn: iirc you also need to leave the inspector open for it to disable the cache

jasonjckn21:06:42

i fear it'll impact user experience though

adambrosio21:06:21

it only impacts developer experience, users should not have this issue

adambrosio21:06:34

as the javascript should be compiled once and served from production

jasonjckn21:06:59

well i'm implementing login/logout through middleware

jasonjckn21:06:15

so dev.html should redirect to login if they're not logged in

jasonjckn21:06:20

through the middleware

jasonjckn21:06:35

right now after /logout is hit, if they navigate to dev.html, it doesn't redirect

jasonjckn21:06:49

until I do Ctrl+F5

tony.kay21:06:36

So, this is not an Untangled issue

tony.kay21:06:42

this is a typical web dev problem

jasonjckn21:06:55

nods sorry i can move to another channel if you want

tony.kay21:06:05

I don't have a general sol'n for you 🙂

adambrosio21:06:22

the fix for the cache is to either ^f5 or do what i suggested earlier

tony.kay21:06:33

figwheel pushes a timestamp query param during dev

tony.kay21:06:40

so if you're using figwheel you should not have a problem

jasonjckn21:06:00

i'm gonna ask the team around here

jasonjckn21:06:07

i think someone knows this

tony.kay21:06:17

but for production purposes...same solutions as with everything. U.S. should be doing proper headers for cache (e.g. date modified)

jasonjckn21:06:43

yah i'm using U.S. in this test, not figwheel

jasonjckn21:06:01

but i'm also adding in middle via pre-hook

tony.kay21:06:03

but if your timestamps on your filesystem fool it (e.g. you move projects and the browser THINKS it has something up to date), then you'll see problems

tony.kay21:06:35

because you're using localhost instead of a real host name

tony.kay21:06:47

you could put aliases to localhost in /etc/hosts...one for each project

tony.kay21:06:58

that way the cache for one app won't screw with the other

tony.kay21:06:19

http://app1.example.com, app2.example.com...that kind of thing

currentoor22:06:20

@mahinshaw: figured it out and it's unsettling. Having [com.fzakaria/slf4j-timbre "0.3.2"] to capture some java logs causes sente to fail.

currentoor22:06:52

It's a small library and I have no idea why it happens 😦

mahinshaw22:06:02

That’s really weird

currentoor22:06:14

but I've confirmed just having that dependency causes sente to fail

mahinshaw22:06:05

It may be worth posting an issue with sente. Is there a specific line of code that fails?

currentoor22:06:01

yeah i'm verifying that adding this dependency in the sente example project fails the same way

currentoor22:06:08

if it does, i'll log an issue

currentoor22:06:44

yup, fails the same way in sente example

mahinshaw22:06:35

Looks like it’s known

currentoor22:06:10

Yeah but it looks like they fixed it in slf4j-timbre 0.3.0 and this is a regression

tony.kay23:06:11

Started work on a reference guide

currentoor23:06:18

So @tony.kay we were wondering when does it make sense to call om/merge! with the additional (albeit undocumented) argument for query? Specifically for websocket subscription stuff. https://github.com/omcljs/om/blob/master/src/main/om/next.cljs#L1630 Did you need to use it in your tech spike? It doesn't seem to be necessary for a simple test case but we may be missing something.

tony.kay23:06:09

So, when you do a server push, you are going to need a UI query (with idents) in order for the incoming data to be normalized and merged properly. The basic answer is "usually"

tony.kay23:06:33

There is a new helper function in untangled.client.core called merge-state! that has some added help

tony.kay23:06:44

and can take an untangled app or reconciler

tony.kay23:06:10

(specifically, it gives you a way to tack idents into the app state at known needed locations)

tony.kay23:06:50

the ident integration is also there as a helper function against a state atom

tony.kay23:06:03

I added those two for our app that is doing push

tony.kay23:06:58

If you're adding new info, then you'll usually have to add the ident to lists somewhere besides the db tables. Your incoming data is going to be a response on a query from an ident join...so it will only really update the targeted table (and linked entities recursively)

tony.kay23:06:34

Say I sent a new person. The query will be something like {[:people/by-id 3] {...}}, which will update the people table...but if you have a list of people in your UI (which is just a list of idents) you'll probably want to either add them to that, or reconstruct (if sorted) the list altogether. So, post mutations are also a possible need.

tony.kay23:06:55

the merge-state! function lets you send just the data of the object (without the join) and it figures out the query using a component. So it keeps you from having to jump through extra hoops (it can use the UI component to derive the correct ident from the object data)

tony.kay23:06:43

so instead of using merge! and having to make up the query by hand, you can leverage what you already have on the UI

tony.kay23:06:35

It also triggers re-render of anything you integrate the ident with

tony.kay23:06:42

So, it actually does quite a few things 🙂

tony.kay23:06:52

hm. now that I think about it...the join wasn't necessary (but it doesn't hurt).

tony.kay23:06:09

probably remove that from the internals of the functoin in the future, but it won't be a visible change