This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-10-26
Channels
- # admin-announcements (1)
- # beginners (167)
- # boot (117)
- # boulder-clojurians (1)
- # cbus (1)
- # clara (3)
- # clojure (87)
- # clojure-conj (2)
- # clojure-japan (2)
- # clojure-russia (23)
- # clojure-spain (3)
- # clojure-za (2)
- # clojurescript (184)
- # community-development (8)
- # core-async (7)
- # core-matrix (4)
- # cursive (36)
- # data-science (74)
- # datascript (3)
- # datomic (171)
- # events (6)
- # hoplon (83)
- # ldnclj (5)
- # ldnproclodo (1)
- # lein-figwheel (2)
- # leiningen (19)
- # liberator (2)
- # off-topic (5)
- # om (227)
- # onyx (5)
- # re-frame (142)
- # reagent (4)
- # yada (5)
Hey all, I’m currently using devcards
from reagent’s lein template. I’m trying to include a function from a specific cljs file. However, for some reason, the function cannot be found. However, if I refer to other functions in the same file, clj doesn’t throw an excpetion.
Has anybody ever experienced this?
I’ve done lein clean
.
hmm, i suspect the files are getting cached
old versions of files are getting cached that is
Adding :devcards
path to lein’s :clean-targets
paths and then running lein clean
does the trick.
@bhauman and anyone who needs figwheel
+ cljsbuild
working inside your application system-map see https://github.com/bhauman/lein-figwheel/pull/266
Could anyone give a piece of advice how to implement textarea with autoresize for Reagent application? I tried to use react-textarea-autosize component, but every time I type something it moves cursor position to the end of the component. Does anyone have ideas how to do it or what can be a problem?
@razum2um: I really wish you would have been in communication with me about this. This is a huge pull request and should be many small ones. I asked you to open an issue for discussion.
@bhauman: feel free to comment on any line, moreover, I think we should start to add tests to be sure, that it’s working, for now you can use my example app to get the idea and prove other things
@bhauman: I feel you started to move into right direction with that big refactor, but if I’m looking a bit into wrong direction - I’m ready to collaborate
@abtv: Will this work for you? https://gist.github.com/rarous/44e03e1f2dd52d13cc31
So I think I’ve painted myself into a corner here with a Chrome extension I’m writing in ClojureScript.
The extension has three major components. There’s the background page, which is doing processing on its own depending on events. Then there’s a display page, that can be used to show some information/settings. Then there’s supposed to be the content script.
The content script is executed when a page matching a pattern is loaded. The behavior I’m getting, however, is that after the ClojureScript code is injected, the page that had rendered just fine is now blank (view-source still returns the expected value).
Haven’t delved too deeply into it yet, but I suspect it’s because the content script code is still coming from the main, unified .js, which has react in it (I use it for the UI on the display page). A test content script on a test project that does not reference react works as expected.
@ricardo: just a guess, but are you using an optimization other than :none
without a :main
?
you'll need 3 seperate builds and the content-script can't be :none
since it must be a single file
@thheller: I am using optimizations on :whitespace
but I do have a :main
- content script on the React-less extension works without : main
too (just tested).
what happens if you use just react.js as your content script?
@mcgivernsa: Let me try and report back.
@mcgivernsa: Found the culprit before I got to that.
@mcgivernsa: It was actually that this build I was testing included devcards, and it was them that were causing the page flash.
@ricardo if you are not using :main
there is a chance that files that aren't actually used are included in your build
React has been exonerated. Still need to split it, since I don’t need all that on the content script, but at least I can do it after testing this bit.
It just shouldn’t have had devcards, which trip page when they get initialized on the content script.
Someone mentions the build settings, you check, they’re as expected… then you notice devcards.
Has anybody successfully used devcards
with re-frame
? I ask because I am attempting to use devcards to demonstrate small, simple examples with re-frame. I thought I’d do this with via dependency injection. However, this is turning out a bit more difficult than I thought. (edited)
For example, https://github.com/Day8/re-frame/blob/e803659a56c7cca574f2d9d88df79307a0e52581/src/re_frame/subs.cljs#L26
I’d like to be able to inject my own database if I need to. However, there’s no hooks (is that the right term?) for me to do so.
I’d love to hear people’s ideas. Forking could be an option.
@kurtlazarus: What part is tripping you? The complete loop?
Nah. I understand and have used re-frame in the past. What I’d like to do is be able to demonstrate parts of the loop in a card.
I’m using devcard and re-frame separately (different projects), but I was wondering how to show the components given that they get their data from the subscription.
My current, untried thinking is having some custom query function for the devcards, which return test data.
In the file I linked above - registrations are just maps of keys and their handler function. Subscriptions are just applying a handler function to a vector.
So I don’t think it should be that difficult.
Thing is… you are already going to have a bunch of register-sub
. It seems like one could just separate the component declaration from the subscription declaration, and just have test register-sub
s initialized with the devcards.
@ricardo: I think one of the main sells for me about devcards is that I can pull bits of actual functionality from my code and document/test/play around with them. Hauman describes figcards as a visual repl that allows you to incrementally iterate on the pieces of code you’re writing. I would love to be able to do the same with re-frame
.
For everything else besides re-frame, this has worked exceedingly well.
Any recommendation for tracking clojurescript errors in production? I'm thinking about yeller, airbrake, sentry, rollbar, etc... Positive and negative experience reports are very welcome
@nblumoe: @tcrayford: should answer this
@kurtlazarus: I have a reimplementation of reframe that nixes all the global variables
I’ve been planning on integrating it with devcards at some point or another, I think it would work really well
it wasn’t to hard was it? like, re-frame’s source code is simple (in a good way) and easy to read)
the major trick is that if you dependency inject in reagent you can’t do it with bindings
@bensu: thanks for pinging @tcrayford, I can imagine a big part of his report 😛. I'd love to hear him critizicing the other services, but don't expect that to happen
that's great I always wondered if you could remove the global
it’s not quite in a good state for public consumption and its been a while since I’ve maintained an OS Clojure lib
honestly, i don’t know what the solution is right now and obviously don’t understand enough of how reagent works and utilizes react under the hood - however, i feel like if bruce could develop a reagent plugin for devcards, re-frame isn’t too far off
i mean, he’s able to throw in tiny bits of state into the cards and demonstrate their capability
maybe it’s a good frame of reference, maybe not
I think @bhauman added experimental reagent support a last week
there’s probably some hackier ways of solving it… and you could always just instantiate global application state and have the devcards all share it
btw, this guy has an open pull request in re-frame: https://github.com/Day8/re-frame/pull/107
He was talking about it earlier today.
So it seems like a lot of different individuals have ideas for improvement - and, from what I gather, the two main devs who author the repo are busy atm (aren’t we all)
the comments in the pull request lead me to believe that they’re hesitant to immediately start accepting merge requests as they have a bunch of apps in production that utilize the library
I don’t understand how there wouldn’t still be bad global interactions with things like register-handler
like, it could isolate the core mechanism, but most re-frame code would still be compatible only with the globally referenced version
@tel: you have to pass around “re-frame” instance, or write some helpers which know which re-frame instance to reference
New library idea: re-frameable
@tel: not necessarily, you can have two namespaces, each holding one set of helpers to talk one re-frame instance
but would be possible with my fork, while still using it the old way, just use proper namespace to talk to preferred re-frame instance
with my fork, it is possible to run many re-frames in the same js context, each will have its own run loop, handlers and subscriptions, but of course when registering handlers, subscriptions and starting run loop, you need to reference proper re-frame instance
@kurtlazarus: I still don’t fully understand what exactly do you want from re-frame to be usable in devcards, do you need isolated re-frame instance per devcard? so each devcard runs its own mini-app?
yea, something like that
basically, i want to iterate from a simple example to a complicated example with re-frame
’s loops
i think being able to iterate from simple to complicated, and seeing that feedback, is very useful
it also would be nice to see what a dispatcher does in isolation - so you could set up different dbs and test them
just like you would for unit tests, etc.
my fork allows all that, for each devcard you setup a brand new pair of app-db and app-frame and start their run-loop
that sounds awesome - i’m gonna check that out
you can also implement event processing a different way, maybe show db evolution step-by-step by applying a sequence of events
that also seems more extensible as well - i could add in middleware to different run loops
I think if this had existed before I started working in cljs I would have used it instead of writing something on my own
> In essence re-frame provides a transducer: state, event -> state.
if you ever needed to track if/when reagent components are being updated by reagent/react, you can look here: https://github.com/darwin/plastic/blob/master/src/main/plastic/reagent/patch.cljs
yea, i like that idea very much
I swap reagents render queue with my own to do benchmarking and logging of updates to componets
that’s an idea that CLJS & JS dev crews have been passing back and forth
and Elm
Does anyone know how to convert a char to an ascii number value in Clojurescript? In Clojure, (int \a)
works fine, for example, but in ClojureScript, this produces 0
regardless of what the char is
I found a solution: (.charCodeAt "StringOrCharIThinkBothAreActuallyStrings" 0)
will convert the character at position 0 of the String
@reefersleep: that’s the right solution
An important lesson for me
thanks @dnolen
any thoughts on how to promote cljs compiler warning WARNING: Use of undeclared Var ...
to an error?
just tried messing with [closure-warnings](https://github.com/clojure/clojurescript/wiki/Compiler-Options#closure-warnings), which can be promoted from warnings to errors
but :undeclared-var is a cljs warning originating from the cljs compiler (not a wrapper around a closure warning/error)
@samumbach: it's already possible to configure ClojureScript warnings to become errors
@dnolen: ok; I'll dig into that; just wanted to check in to see what the recommendations are
@dnolen: is throwing an exception the right way to bail out of the compiler? or is there some other function I should be using?
sorry to barge in, I confirm you need binding [ana/*cljs-warning-handlers* [ function ] ...
@richiardiandrea: yup; I'm now following along with https://github.com/emezeske/lein-cljsbuild/issues/225 and https://github.com/emezeske/lein-cljsbuild/pull/370
in my code the error is added in an atom and "summed up" to the result of eval-str
to produce an error instead of success in case a warning is thrown
@richiardiandrea: are you throwing an exception to produce that error?
nope because it is not my use case
but you can, you just need to store the warning somehow because it will be handled in your warning handler
and eval-str will produce another result...
@richiardiandrea: you mentioned "to produce an error instead of success in case a warning is thrown" - how are you producing an error?
@samumbach: yes you can do whatever you like in the handler
in my case I have a callback and everything goes inside it
but how you produce the error is application dependent
@richiardiandrea: you mentioned collecting messages into an atom? is there some hook you use to perform an action after the build is finished?
mmm I use warning-handler and the call eval-str
the result of the two is merged
and if there is a warning I show an error in my UI
@dnolen: thanks; (System/exit 1)
is probably a better fit for me than raising an exception
@richiardiandrea: I'm not familiar with eval-str
; is that from cljs? clojure? leiningen?
sorry, it is from cljs.js
clojurscript core
i mean clojurescript 😄
@richiardiandrea: ah, so you're somehow injecting the cljs compilation warnings into the .js output?
it is simple, not rocket science trust me, it is just an entry in an atom and a common exit point for your functions
but again, I don't know how you're handling stuff
ah, then it is easy
because cljsbuild allows you to specify your warning handler if I am not wrong..
clj
(defproject foo "0.1.0-SNAPSHOT"
,,,
:cljsbuild {:builds [{:id "dev"
,,,
:warning-handlers [(fn [warning-type env extra]
(if (#{:undeclared-var} warning-type)
(let [msg (cljs.analyzer/error-message warning-type extra)]
(binding [*out* *err*]
(println (cljs.analyzer/message env (str "ERROR: " msg))))
(System/exit 1)))
(#'cljs.analyzer/default-warning-handler warning-type env extra))]
}]})
cool, does it work?
@richiardiandrea @dnolen thanks for all your help 😀
great!
that didn’t take very long https://twitter.com/sendmehome/status/658772964729487360