carry

kauko 2016-07-01T05:24:56.000206Z

btw, we spoke about the debugger-added? thing a few days ago, and you said the whole debugger code would be added in a production build if I use that function

kauko 2016-07-01T05:25:23.000207Z

but doesn't the closure compiler optimise imports in a way that only that function will be included, if it's all I use?

metametadata 2016-07-01T10:06:37.000208Z

@kauko: I think that Closure compiler can't optimize it in a way you describe because it can't determine during static analysis that debugger-added? would always return false. My theory was that maybe you won't be needing debugger-added? if code is restructured in such a way that debugger is not included in production build, e.g. if you have 2 separate build profiles and main files.

kauko 2016-07-01T10:22:18.000209Z

but (debugger-added?) doesn't need anything else from the namespace

metametadata 2016-07-01T10:26:40.000210Z

Wouldn't you also need debugger/connect required?

kauko 2016-07-01T10:27:17.000211Z

ohh

kauko 2016-07-01T10:27:19.000212Z

you're right

kauko 2016-07-01T10:27:21.000213Z

crap 🙂

metametadata 2016-07-01T10:27:24.000214Z

OK )

kauko 2016-07-01T10:28:26.000215Z

oh well, one solution would be that my "main" function will take a react component as a parameter, and it will either be nil, or the debugger

kauko 2016-07-01T10:28:40.000216Z

that's not too bad

metametadata 2016-07-01T10:36:11.000217Z

Maybe you could move view initialization code closer to the app spec definition (as they seem kinda coupled)? So that you don't have to determine if debugger was added in spec or not dynamically.

metametadata 2016-07-01T12:15:56.000218Z

Added notes about usage with Devcards and REPL into User Guide: https://metametadata.github.io/carry/user-guide/#usage-with-devcards https://metametadata.github.io/carry/user-guide/#usage-with-figwheel-and-repl

kauko 2016-07-01T12:28:41.000219Z

❤️

kauko 2016-07-01T12:32:20.000220Z

I'll have to see how to make the :on-start signals work with Rum

kauko 2016-07-01T12:32:28.000221Z

and maybe add a section to the guide about Rum

kauko 2016-07-01T12:32:51.000222Z

the first time I read them I was confused whether Carry works with other view libraries besides Reagent (I asked about that on reddit)

metametadata 2016-07-01T12:36:28.000223Z

:on-start/:on-stop signals are kinda orthogonal to Rum so you shouldn't have much trouble with them

metametadata 2016-07-01T12:52:20.000224Z

I was thinking about simply back-linking to carry-rum project in case you publish it (incl Devcards integration, server-side rendering and other docs)

martinklepsch 2016-07-01T12:55:00.000226Z

@metametadata: @kauko regarding the debugger-added? thing — if you use :closure-defines with the proper type hint the compiler is smart enough to remove stuff that can't be reached

metametadata 2016-07-01T12:58:10.000227Z

@martinklepsch: cool, I didn't know about this feature

martinklepsch 2016-07-01T12:58:11.000228Z

This might be helpful to understand the possibilities/getting started: https://www.martinklepsch.org/posts/parameterizing-clojurescript-builds.html

👍 1
metametadata 2016-07-01T12:59:37.000230Z

offtopic: do you have an RSS feed for the blog?

martinklepsch 2016-07-01T13:00:36.000231Z

@kauko: If you're using carry & rum how are you handling the view model aspects? I made a little thing to help with that (not specific to carry) which I'd be interested in getting some feedback on

martinklepsch 2016-07-01T13:02:16.000232Z

@metametadata: unfortunately not right now

metametadata 2016-07-01T13:05:13.000233Z

@martinklepsch: ok, just wanted to subscribe 🙂

kauko 2016-07-01T13:32:55.000234Z

@martinklepsch: I just pretty much copied the reagent-carry module

martinklepsch 2016-07-01T13:53:25.000237Z

@kauko: ah ok, so you don't have many view-models yet

kauko 2016-07-01T13:57:40.000238Z

uhm

kauko 2016-07-01T13:57:56.000239Z

Well, yeah I guess, I've hardly started on the project

kauko 2016-07-01T13:58:13.000240Z

but I guess I misunderstood your question, what does the number of view-models have to do with this? 🙂

martinklepsch 2016-07-01T14:07:54.000241Z

In re-frame I've had many subscriptions with different data in different forms, I guess in carry you'll similarly end up with multiple view models which are tailored to the situation you want to use them in. Carry's spec based approach inspired me to try doing something similar to subscriptions/view-models which lead me to something like this: https://gist.github.com/martinklepsch/c5a2feacc63ce08565fcffe37951ab64

martinklepsch 2016-07-01T14:11:40.000242Z

There's a lot of documentation missing from this but essentially 1) take a component/system like spec and create a bunch of derived-atoms based on the dependency information 2) provide a rum mixin that puts functions into childContext which can be used to get! and release! these derived atoms, essentially acting like a resource pool (while allowing multiple resource users) 3) provide some sugar to use the functions in the component context

kauko 2016-07-01T14:20:45.000243Z

Hmm, I'm not sure I really grasp what problem this solves. Carry's view-models are optional, they just get the model and return data that the view cares about, with a structure the view understands.

kauko 2016-07-01T14:22:24.000244Z

without a view-model, each component would just get the whole model

kauko 2016-07-01T14:26:23.000245Z

Actually that got me thinking, don't pretty much all components have to take the whole model as a parameter anyway if they have child components? Unless you want the component to care what kind of data the child component takes

kauko 2016-07-01T14:26:43.000246Z

that probably depends on how high in the component tree you are

martinklepsch 2016-07-01T14:42:26.000247Z

The problem this solves is creating inter-dependent view-models (similar to re-frame's dynamic subscriptions) and getting them to the components that need them

martinklepsch 2016-07-01T14:42:38.000248Z

I will write some docs later today

kauko 2016-07-01T16:31:26.000249Z

Hmm, I'm trying to use the carry-atom-sync with devcards, but the data inspection / history stops working after one interaction

metametadata 2016-07-01T16:33:24.000250Z

just in case - make sure you use v0.2.0

kauko 2016-07-01T16:37:36.000251Z

I am

kauko 2016-07-01T16:37:46.000252Z

and it seems to work fine in my application

metametadata 2016-07-01T16:46:38.000253Z

@martinklepsch: when you use term "view-model" do you mean a single derived atom (akin to re-frame's subscription) or a bunch of atoms? In Carry+Reagent view-model is usually a map of multiple reactions.

metametadata 2016-07-01T16:49:04.000255Z

Carry's view-model kind of corresponds not to a single re-frame's subscription, but to the set of subscriptions.

metametadata 2016-07-01T17:01:26.000256Z

>Actually that got me thinking, don't pretty much all components have to take the whole model as a parameter anyway if they have child components? Unless you want the component to care what kind of data the child component takes It depends on the type of component. You can have top-level container/smart components which take in a reactive view-model (or a bare model if don't want to bother with vm layer) and also more reusable presentational/dumb components like a "button", "report-graph" etc. which have static props. This dichotomy is described in this article by Dan Abramov: https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0

kauko 2016-07-01T17:02:35.000259Z

makes sense

kauko 2016-07-01T17:02:52.000260Z

I really can't get the atom-sync thing to work with devcards o.O

kauko 2016-07-01T17:03:13.000261Z

it works fine if I use a hacky version of carry/app that takes the model-atom as a parameter

kauko 2016-07-01T17:03:27.000262Z

the atom sync also works fine in my normal app

kauko 2016-07-01T17:03:47.000263Z

but with devcards the card's data is updated once, but then stops updating

metametadata 2016-07-01T17:03:59.000264Z

do you use defcard?

metametadata 2016-07-01T17:05:56.000265Z

I guess I had some similar problem until I switched to defcard-rg

metametadata 2016-07-01T17:08:10.000266Z

yeah, I think that's the problem - I can reproduce your issue when after switching to defcard

metametadata 2016-07-01T17:10:39.000267Z

adding :watch-atom false option seems to fix the problem, though I don't know why )

kauko 2016-07-01T17:11:24.000268Z

huh, that works

kauko 2016-07-01T17:12:29.000269Z

:watch-atom true ;; whether to watch the atom and render on change

kauko 2016-07-01T17:12:49.000270Z

interesting

kauko 2016-07-01T17:13:23.000271Z

I get that there can be conflicts, but it's surprising that I didn't need to set that to false when using my hacky version of carry/app

metametadata 2016-07-01T17:15:06.000272Z

yeah, hard to tell without digging into devcards code

kauko 2016-07-01T17:17:04.000273Z

hm

kauko 2016-07-01T17:17:22.000274Z

well, anyway, works nicely now 🙂

martinklepsch 2016-07-01T18:20:03.000275Z

@metametadata: ah ok, i thought the view model is one derived atoms and you'd have multiple of them

martinklepsch 2016-07-01T18:20:52.000276Z

@metametadata: how does it work if you don't use one of the reactions in the view model map? Are they computed anyways?

metametadata 2016-07-01T18:58:52.000277Z

@martinklepsch: Yeah, here's a VM from TodoMVC example: https://github.com/metametadata/carry/blob/master/examples/todomvc/src/app/view_model.cljs Reaction is not recalculated if noone is watching it. But I've also read that creating a reaction and never using it can be considered an error because it causes a memory leak.

metametadata 2016-07-01T19:08:04.000284Z

Here's a reply to re-frame issue explaining why not using reaction/subscription is a leak: https://github.com/Day8/re-frame/issues/29#issuecomment-81132123

martinklepsch 2016-07-01T19:08:15.000287Z

Ah I see reagents reactions do have some extras for efficiency :)

martinklepsch 2016-07-01T22:32:33.000288Z

@metametadata: @kauko here are the docs I said I would write: https://gist.github.com/martinklepsch/c5a2feacc63ce08565fcffe37951ab64 — hope this makes sense in the context of what we talked about earlier. In comparison to Reagent's Reactions this feels a bit simpler and more explicit to me but I'm also not overly familiar with the reaction impl.

metametadata 2016-07-01T23:03:35.000289Z

The intro/usage is nice and easy to understand. It looks similar to reactions but is implemented using data-centric approach instead of macros. Kinda. Cons: Rum-related stuff is not demonstrated and subman name is odd, also I don't quite get what's going on in (comment ..) blocks 🙂

metametadata 2016-07-01T23:10:10.000290Z

Maybe the lib may also benefit by providing a comparison example: lib's build vs. using raw derived-atom calls in and putting them into a map.