mount

tolitius 2016-01-12T00:54:43.000252Z

@fappy, interesting. I noticed that recently some of the circle builds randomly fail due to cljs tests complaining about cleanup-if-dirty, but then they get rebuilt, and the problem goes away. might have to do with an order things get compiled / referenced.

tolitius 2016-01-12T00:55:04.000253Z

where do you need to :refer the actual function?

tolitius 2016-01-12T00:55:32.000254Z

(i.e. I know it is a problem, since I see it happens sometimes, but did not pinpoint the reason yet)

tolitius 2016-01-12T01:07:50.000258Z

@fappy: 0.1.9-SNAPSHOT has it public. Let me know whether it works better for you

2016-01-12T17:47:33.000262Z

@tolitius: it works as long as I :refer [cleanup-if-dirty] ... I suppose it's because I'm in ClojureScript and the defstate macro expansion refers to cleanup-if-dirty

2016-01-12T17:48:39.000263Z

@tolitius: perhaps if defstate is the only one who uses cleanup-if-dirty then it can be a local let-fn inside the macro expansion and cljs users would not need to :refer it in addition to defstate?

2016-01-12T18:27:24.000264Z

@tolitius: a second question: in ClojureScript, it looks like a defstate is not actually :started until the moment someone @ deref's it --- that is, :refering it is not enough to :start a dependency.... Is this as-designed (the start-up order for everything will be the same) or is this an unexpected difference from pure Clojure?

tolitius 2016-01-12T19:49:01.000269Z

@fappy the rational for derefing is here: https://github.com/tolitius/mount/blob/master/doc/clojurescript.md#managing-state-in-clojurescript (long story short, in cljs :advanced you can't rely on several Clojure namespace API) but if you are not planing to use :advanced to start with, you don't have to go into cljc mode

tolitius 2016-01-12T19:49:57.000271Z

as to cleanup-if-dirty, you still need to :refer it for 0.1.9-SNAPSHOT?

tolitius 2016-01-12T19:50:54.000272Z

since we already have several cljs projects that use mount (+ the mount cljs example app: https://github.com/tolitius/mount/tree/master/dev/cljs/app) and they do not need to require it..

tolitius 2016-01-12T19:51:57.000274Z

can you run boot test-cljs or lein do clean, doo phantom test once (whichever you prefer) from the mount root and see if it passes for you?

tolitius 2016-01-12T19:52:07.000275Z

I understand that your env is different, but it's a good start

2016-01-12T20:10:53.000276Z

oh you mean with a mount clone, in order to test my env?

2016-01-12T20:14:00.000277Z

haha. that means building phantomjs --> 30 min

tolitius 2016-01-12T20:14:03.000278Z

right, not exactly your project, but just to rule out something env specific

2016-01-12T20:14:29.000279Z

sure ok

tolitius 2016-01-12T20:15:27.000280Z

$ time lein do clean, doo phantom test once       0.1.9-SNAPSHOT

;; =============================================================
;; Testing with Phantom:


Testing mount.test.fun-with-values

Testing mount.test.private-fun

Testing mount.test.parts

Testing mount.test.cleanup-dirty-states

Testing mount.test.stop-except

Testing mount.test.start-without

Testing mount.test.start-with

Testing mount.test.suspend-resume

Ran 9 tests containing 71 assertions.
0 failures, 0 errors.

12.66s user 1.16s system 142% cpu 9.704 total

tolitius 2016-01-12T20:15:31.000281Z

not too bad :simple_smile:

2016-01-12T20:15:56.000282Z

yeah. just have to get phantom first

2016-01-12T20:16:20.000283Z

all my project needs is node so I don't yet have phantom

tolitius 2016-01-12T20:26:59.000284Z

oh.. you can just run boot test-cljs

tolitius 2016-01-12T20:27:12.000285Z

or do you have get boot for that? :simple_smile:

tolitius 2016-01-12T20:27:22.000286Z

good thing to get regardless

2016-01-12T20:36:41.000290Z

that still requires phantom which is still in the process of --recurse-submodules before building from source

tolitius 2016-01-12T20:40:51.000291Z

if it is a problem, there are a couple of other things to try: 1. You can run a cljs example app, and see if it works for you (it does not have :require cleanup-if-dirty) 2. You can give me something to checkout and try, if that is ok, of course

tolitius 2016-01-12T20:41:36.000292Z

for #1: boot cljs-example

tolitius 2016-01-12T20:41:59.000293Z

or "lein via figwheel"

2016-01-12T21:10:25.000294Z

may have to give you something since phantom build from source failed on my machine. (it didn't think libQt5Bootstrap.a was compatible when searching for libQt5Bootstrap.a)

2016-01-12T21:10:44.000295Z

(going to eat first though)

tolitius 2016-01-12T21:11:37.000296Z

sure, no need for phanton.. should not be that complex

2016-01-12T22:23:27.000297Z

@tolitius: https://github.com/frankhenderson/mount-question is an almost minimal repo of the warning in my environment

2016-01-12T22:24:22.000299Z

@tolitius: I get the warning when I do lein figwheel dev

tolitius 2016-01-12T23:00:05.000300Z

@fappy thx, will look later today

2016-01-12T23:05:48.000302Z

@tolitius: I think all I needed was to add (mount/in-cljc-mode) to my core namespace. The warning is gone now.

tolitius 2016-01-12T23:15:54.000305Z

you'll definitely need it, if you are going as far as ClojureScript production deploys, since then you'll use :advanced compilation optimization level, which would mangle all the namespaces

tolitius 2016-01-12T23:16:50.000306Z

glad it works, and that is probably why we have not seen it before since, so far everyone I know using mount on cljs do run it cljc mode. I would still like to understand the reason though.. :simple_smile:

2016-01-12T23:16:58.000307Z

Well... this will just be a server-side app. In cases where I don't care about disk usage, I won't have to use :advanced ... there will be no downloading of my generated js

tolitius 2016-01-12T23:18:10.000308Z

I see.. if you don't mind to run in this mode for now, that would be good. I'll try to piece together the reason.

tolitius 2016-01-12T23:18:26.000309Z

to refactor out of this mode is just to remove @s

2016-01-12T23:19:06.000311Z

ok thanks. (I still have to learn how to use the generated source-map to make sense of the mangled names in a stack trace. I think the browser does it for everyone else but my use case doesn't include a browser!)

tolitius 2016-01-12T23:19:41.000312Z

yea, that's definitely an interesting use case

2016-01-12T23:20:00.000313Z

I'll just run in cljc mode but keep optimization at :none

tolitius 2016-01-12T23:21:01.000314Z

yea would definitely help to read source maps

tolitius 2016-01-12T23:30:09.000315Z

yea.. that's definitely not your env or anything on your side:

boot.user=> (start-repl)

cljs.user=> (require-macros '[mount.core :refer [defstate]])
nil
cljs.user=> (defstate a :start 42)

clojure.lang.ExceptionInfo: Unable to resolve var: cleanup-if-dirty in this context at line 1 <cljs repl> {:file "<cljs repl>", :line 1, :column 1, :tag :cljs/analysis-error}

cljs.user=>

cljs.user=> (require '[mount.core :as mount])
nil
cljs.user=> (mount/in-cljc-mode)
:cljc
cljs.user=> (defstate a :start 42)
#'cljs.user/a
cljs.user=> a
#object[mount.core.DerefableState]
cljs.user=> @a
42

tolitius 2016-01-12T23:49:04.000318Z

@fappy: looks like (:require [mount.core]) at the app entry should be enough. no need to run it in cljc mode

tolitius 2016-01-12T23:49:10.000319Z

let me know whether it works for you

2016-01-12T23:54:18.000322Z

@tolitius: yes that works for both the minimal example and my project

tolitius 2016-01-12T23:57:51.000323Z

@fappy: cool. I am not a cljs guru, so the best way to tackle this needs some research :simple_smile: but I think it's not unreasonable to "require" at the app entry for now, as long as it is documented

2016-01-12T23:59:27.000324Z

what do you mean by app entry ? I put the :require in the ns which gave the warning.... Do you mean put it in my core ns ?