Fork me on GitHub
#clojurescript
<
2019-04-03
>
Average-user02:04:24

How can I load an .md file as html into a cljs component?

Average-user02:04:47

The idea is to have large text files written in md over having them in cljs or html directly

Average-user02:04:47

The idea is to have large text files written in md over having them in cljs or html directly

orestis03:04:15

Make a macro that reads the file. Take note of caching issues. I recall shadow-CLJS has something like that already...

tomaas09:04:28

hi, how do i extract this of this c3 chart in the onrendered method?

oconn11:04:48

@tomaas Have you tried using https://cljs.github.io/api/cljs.core/this-as in the onrendered function?

abdullahibra11:04:50

what are your suggestions about using kafka with clojure with reagent, for example we could assume counter example, inc per click, so i should use web sockets or rest api?

abdullahibra11:04:39

what i missing is how can i interact with kafka from the UI ?

cjohansen12:04:53

can I use cljs.build.api/build to build from multiple directories?

cjohansen12:04:36

I'm splitting up my app, and currently have ui/src and app/src, and now I want to build a single artifact from these two

thheller12:04:42

yes, see cljs.build.api/inputs

cjohansen12:04:10

ah, cool. so just pass the result of inputs as source?

thheller12:04:02

i think so yes

cjohansen12:04:17

(cljs.build.api/build (cljs.build.api/inputs "ui/src" "app/src") compiler-ops) worked, thanks!

yogidevbear12:04:53

Hi everyone. What is the best library to use for working with urls these days (e.g. for iterating over query parameters, etc.)? I was thinking of using https://github.com/cemerick/url but not sure if this is a good idea due to the read-only notice at the top of that page. I'm guessing this is because it is essentially feature complete, but wanted to check with the wider ClojureScript community before making a final decision.

oconn13:04:01

@yogidevbear For manipulating URLs I’ve used cemerick/url and found it useful. It’s a very small lib (141 loc) that uses goog.Uri so you could look at those libs as well. In my client apps I typically leverage routing libs (bidi, etc…) to parse route state.

👍 4
orestis13:04:47

Any opinions on doing internationalization/localization? Ideally I’d like to use a widely-used and stable JS framework for the nitty gritty, e.g. https://formatjs.io or https://www.i18next.com — if anyone has experience with those it’d be cool to share thoughts! I looked at Google Closure stuff but their method relies on making a separate js bundle per locale, which is not my cup of tea at the moment.

lread18:04:02

Hello ClojureScriptians! I am in the midst of bringing rewrite-cljs up to par with rewrite-clj. Rewrite-clj makes use of an internal version potemkin’s import-vars. The import-vars macro allows you to collect fns (and defs and macros) from disparate namespaces into an api namespace. With the goal of a single code base, I thought I’d experiment with making a cljs version of import-vars - at least for fns. It is mostly working, with one known problem: I see :file and :line returned by cljs.analyzer.api/resolve on my disparate fns, but have not figured out a way to apply :file and :line as metadata to the fns in my api namespace. The goal is for it to behave like the clj import-vars so that when requesting source (for example via cljdoc) on fns in the api namespace you are taken to the source of the fns in the disparate namespaces. Any tips?

dnolen19:04:10

you will need to fix that information in the ClojureScript compiler state

dnolen19:04:09

but in general I don't see how this will be useful since a lot of tooling relies on source mapping

dnolen20:04:02

to clarify my first point

dnolen20:04:05

there are no vars

dnolen20:04:12

so there's nothing to set in that regard

dnolen20:04:02

instead ClojureScript has compiler state which has a mapping of all namespaces and their defs

dnolen20:04:21

and every def has a map with things you would normally find in var metadata along w/ other useful compiler related stuff

lread20:04:21

Thanks very much @dnolen, that helps me to understand. Do you have a general opinion on potemkin’s import-vars? From my (admittedly naive) position it seems like an elegant way to expose an api.

dnolen20:04:32

I don't like it 🙂

dnolen20:04:05

just require stuff and keep things organized, don't over organize

dnolen20:04:16

you may have to write a little boilerplate if you really want to do impl namespaces

dnolen20:04:37

but so far in all my time w/ Clojure(Script) I prefer that over such "helpers"

dnolen20:04:14

but that's just a matter of taste

dnolen20:04:26

I think you can accomplish the same thing w/ my points above

lread20:04:00

Thanks again, that helps. I am not new to software dev, but am relatively new to Clojure/ClojureScript.

dnolen20:04:39

you'll definitely learn a thing or two about ClojureSript internals if you try to get this to work - not a bad thing

lread20:04:18

Hmmm… that puts an interesting spin on it!

dnolen20:04:51

reading the cljs.analyer.api ns should give you an idea of what accessing the compiler state looks like

dnolen20:04:06

then you will need to update-in the right def

lread20:04:59

Hmmm… I like a good puzzle, but maybe that’s all this is. I could be done pretty quickly and very reliably with some boilerplate.

dnolen20:04:16

basically (import-var x) should expand to whatever makes sense, but also side-effect (inside the macro fn, not the returned source) the new def in the compiler state to give it the desired :line and :file

lread20:04:13

ok, I am too tempted not to try it. thanks so much for taking the time to help!

lread20:04:10

while you are here… and if you are willing… when you guys ported Clojure to ClojureScript did you run into many cljs namespace clashes? I’ve hit some in rewrite-clj and am weighing my options.

lread20:04:47

actually, ironically, they are all due to collecting fns into an api namespace which is a pattern that is probably not in the Clojure codespace?

dnolen20:04:59

namespace clashes only really happens w/ macros - is that what you're referring too?

dnolen20:04:32

that is you have an existing Clojure namespace you don't want to change, and a ClojureScript namespace w/ the same name but that needs macros

lread20:04:37

I was thinking of clashes due to Google Closure namespaces https://clojurescript.org/about/differences#_namespaces

dnolen20:04:18

right - we fixed the more problematic cases a long time ago

dnolen20:04:27

but you still have to worry about the basic case of

dnolen20:04:50

cljs.foo/bar cljs.foo.bar/baz

lread20:04:24

Yes, that’s the stuff I am running into… things like rewrite-clj.zip.coerce and rewrite-clj.zip/coerce

dnolen20:04:28

if I recall we just punted on that

lread20:04:30

I guess I just have to rename the function or the ns, no way around it, right?

dnolen20:04:05

because you run afoul of ordering issues

dnolen20:04:49

i.e. do you rename the var or the ns ... but maybe you won't see them in the same order because of incremental compilation, require changes etc.

dnolen20:04:14

it could probably be made to work - but it's annoying enough that no one has given it a go

lread20:04:23

whatever I choose, someone is going to be annoyed with me! 🙂

dnolen20:04:34

also munging nses makes debugging harder

dnolen20:04:52

since ns munging is pretty straightforward, it's easy to debug even in limited JS environments

dnolen20:04:21

anyways - those are the high level reasons we backed away slowly from this problem

dnolen20:04:38

and I believe we warn?

lread20:04:47

yep, which is kind

dnolen20:04:59

so if you don't get a warning about detected clashes that's what I would consider the bug

lread20:04:43

it is a tiny annoyance in a what is a beautiful thing!

lread20:04:16

thanks for being so generous with your time,

lread20:04:23

it is much appreciated.

dominicm20:04:11

What's the difficulty with prefixing or suffixing namespaces/vars?

dnolen20:04:19

makes debugging harder

dnolen20:04:34

you have to remember the magic prefixing at the JS console

dnolen20:04:54

remember ClojureScript isn't just about browsers

dnolen20:04:47

IMO big loss for minor gains

dnolen20:04:10

having tried debugging ClojureScript in many different environments