admin-announcements

Announcements from the Clojurians Admin Team (@U11BV7MTK @U077BEWNQ @U050TNB9F @U0ETXRFEW @U04V70XH6 @U8MJBRSR5 and others)
sveri 2015-12-22T09:06:58.002225Z

Hi, how can I tell prismatic schema a value in a map could be nil or string?

robert-stuttaford 2015-12-22T09:19:15.002226Z

there’s always s/pred

mccraigmccraig 2015-12-22T09:22:02.002227Z

@sveri: or (s/maybe s/Str)

sveri 2015-12-22T09:22:18.002228Z

ah, so I can just leave out nil

sveri 2015-12-22T09:22:25.002229Z

that makes sense, thank you both

2015-12-22T11:09:01.002231Z

regarding schema - how do you guys organize your schema code? do you put your schemas next to the place you create data or you have a separate namespaces for schemas?

mccraigmccraig 2015-12-22T11:13:55.002232Z

@andrut: both, depending on usage. i've got some schemas which are shared between cljs ui and clj backend which are in their own namespaces, and others which live near the code which uses them

2015-12-22T11:15:37.002233Z

I’ve got quite a lot of same data structures that are being passed around the whole application; maybe I should put it into records and use this as schemas or should I leave it as plain maps and define schemas somewhere… :simple_smile: but thanks for your answer, @mccraigmccraig

sveri 2015-12-22T14:06:04.002236Z

@andrut: I also have on file containing my schemas which are shared

👍 1
sveri 2015-12-22T14:20:31.002237Z

Hi, I lately switched from component to mount. Now I see a behavior I find strange, but I am not sure if that did happen before with component too. So, I have several things defined with defstate. I use Cursive and whenever I adapt a function in a namespace and reload that changed function into the REPL the component, that that code belongs to, is stopped and I have to start it manually again. This is somewhat unexpected as most of my components stop after changing some code.

eggsyntax 2015-12-22T14:24:04.002238Z

@jonpither: post in #C0F0V8DT5 & you’re likely to find some help.

sveri 2015-12-22T18:57:53.002241Z

I just put it all back to components and at the first glance the problem has gone now

roberto 2015-12-22T18:58:41.002242Z

that sucks. I just started using mount on a new project. Would suck if I don’t get code reload.

roberto 2015-12-22T18:58:51.002243Z

Did you use the dev.clj file in the example?

sveri 2015-12-22T19:25:45.002245Z

@roberto Don't get me wrong, it does reload the code. But, what it does, is, to stop some components

sveri 2015-12-22T19:25:50.002246Z

And I have to start them manually

sveri 2015-12-22T19:25:54.002247Z

It works afterwards again

sveri 2015-12-22T19:26:00.002248Z

but, that extra step bugs me

sveri 2015-12-22T19:26:19.002249Z

OTOH I have several complex with a lot of dependencies thrown together, the cause might also be a different library

sveri 2015-12-22T19:26:41.002250Z

So, not sure if it is really mounts fault or someone elses, I just think the tendency is there

sveri 2015-12-22T19:28:21.002251Z

I also searched github for how others used it and did not really find any repos doing so. That means it is in kind of early adopters state and I think there are more bugs around that are not found yet.

2015-12-22T20:27:19.002252Z

FYI i created a channel #C0GQAAKA9 for discussions related to component-based workflow

sveri 2015-12-22T21:58:15.002257Z

@settinghead: thanks, didn't know that

tolitius 2015-12-22T22:51:37.002258Z

@sveri: when you reload code which does not have any states defined, it reloads as you would expect. when you reload with states defined and started, new states are created with, potentially, new changes introduced before recompilation. hence before creating these new states, mount cleans up any resources old states might be still using by calling their :stop functions. currently (starting from 0.1.7) mount will tell you when it happens: https://github.com/tolitius/mount/issues/22#issuecomment-164834038 if you are using the reloaded workflow, you can simply (reset) if this happens, and/or you can do (mount/start #'this.state). I understand that it is an extra step, you can open an issue on the github and we can definitely discuss whether mount should just start these new states after a namespace was recompiled, or ignore certain states on recompile if they are not occupying any resources, etc.. so things are more transparent

tolitius 2015-12-22T23:04:04.002262Z

@sveri: another thing to consider is how to organize the code with "states". I tend to agree with @yogthos that it is best to > "keep the code that interacts with external resources at the edges of the application. The core business logic should be pure and testable, while anything that deals with side effects and external resources should be pushed to a thin layer around it" source: http://yogthos.net/posts/2015-12-05-LuminusComponents.html in which case reloading the code with states would not be often at all. I would still like to discuss it though, since I am interested in the useful behavior, so feel free to open a github issue