This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-19
Channels
- # aws (9)
- # bangalore-clj (1)
- # beginners (6)
- # cider (17)
- # cljs-dev (9)
- # cljsrn (31)
- # clojure (70)
- # clojure-spec (19)
- # clojurescript (122)
- # cursive (1)
- # datomic (20)
- # dirac (8)
- # fulcro (19)
- # hoplon (25)
- # instaparse (2)
- # lambdaisland (3)
- # luminus (8)
- # lumo (10)
- # om (22)
- # parinfer (25)
- # protorepl (2)
- # re-frame (35)
- # reagent (1)
- # test-check (5)
- # unrepl (6)
@symfrog what do you mean by fails?
oh I can repro
@symfrog hah, figured it out. the processed file doesn’t export a namespace
there’s no goog.provide
so we can’t figure out what it provides
@anmonteiro Would cljs or closure allow npm packages such as this to be consumed for their side effects (in the bootstrap.js case adding a plugin to jQuery) in the future or would I have to specify a foreign lib for it?
@amitayh cool! How about a bit more explanation of your work on the github page 🙂
@andreasklein thanks 🙂 i will write a more detailed explanation soon. programmers enjoy writing the code better than the documentation 🙂
@amitayh One thing I don’t get yet is how ->Increment or generally ->Message works. As far as I see this is the construction of a record. But how does this record end up in your messages channel?
this is handled in render.cljs
. i’m transforming the view data into a react component
every callback (`onSomething`) is wrapped to send the resulting message to the messages channel
Thanks I see it now. This is “react magic” happening in to-prop
I find ->Message very esthetically pleasing
yes, it’s similar to how it actually looks in elm: https://guide.elm-lang.org/architecture/user_input/buttons.html
view : Model -> Html Msg
view model =
div []
[ button [ onClick Decrement ] [ text "-" ]
, div [] [ text (toString model) ]
, button [ onClick Increment ] [ text "+" ]
]
I think it’s even more clear because of the sending arrow ->
is there some function that converts HTML into the equivalent hiccup style definition?
it seems mostly a mechanical process anyway so should be possible I guess
@andrea.crotti yes search for html2hiccup on Google, you'll find two or three online services
Hello, I want to ask how can I put @ in hiccup attributes? [:div {:data-uk-icon@s "icon"}] won't work because @ wants to deref (UIkit)
Try (keyword “data-uk-icon@s”)
But the obvious question is: Why are you doing this? What benefit do you expect?
What do you mean? It is needed for responsive behaviour.
Ah ok your library/framework/something forces you to do this.
yes, UIkit needs it. Btw data-uk-column-1-5 works, escapes the camelcase. But data-uk-column-1-5@s still doesn't work, wants to dereference 😕
Even when you wrap it into a keyword?
yea, it works, thank you, very much appreciated
Cool I just tried it in sablono and it doesn’t work, react tell’s me it’s an unknown prop. Glad to be able to help you.
well, you may need the framework to initialize these specific props, anyway it works now
cljs numbers are js doubles. does cljs also have arbitrary precision integers ? (I think they're called 'bigints')
I just found out about webjars (by looking at an example luminous project) https://www.webjars.org/
how do they differ from packages on cljjs?
maybe they are simply packaged css/js with 0 Clojure extra mapping?
@qqq There is no arbitrary-precision arithmetic capability in the core runtime. I haven't tried https://github.com/gfredericks/exact
Is there any issue in the cljs community in regards to the license that React operates under? I was looking for a similar library that implements Vue.js, purely for licensing reasons, but it doesn’t seem to exist
@mv I haven't seen a community-wide issue or stance. It seems to be up to individuals or companies take a decision.
@mfikes Yea, but if you are advocating cljs it seems like you are forced to lean into the worse licensing situation
back to the your other point - not aware of Vue.js bindings - seems like somebody should work on that
@dnolen I figured, but it thought about it again because of https://code.facebook.com/posts/112130496157735/explaining-react-s-license/
part of the reason React got popular in ClojureScript is because it’s easy to write a functional wrapper for
Yea, this was all assuming it’s as much of a drop in replacement for React as I have heard
@nagarajan there’s lot of known issues - describe your problem and someone can let you know if it’s been addressed
For every react component I tried to install via npm, I get Uncaught ReferenceError: require is not defined
in browser console
I tried react-player "0.20.0"
and react-date-range "0.9.4"
. For both of these , I got the similar error
:npm-deps {:react-date-range "0.3.0"}
in the project.clj.
after building, if I include react-date-range
or "react-date-range"
namespace, I get Uncaught ReferenceError: require is not defined
error.
I also get WARNING: JSC_JS_MODULE_LOAD_WARNING. Failed to load module "react" at ..../node_modules/react-date-range/lib/Calendar.js line 19 : 4
msg while compiling
@nagarajan looks like you’re not adding :react
to your :npm-deps
@anmonteiro I included :react "15.6.1" :react-dom "15.6.1"
. Still same errors and warnings
@nagarajan so first problem. react-date-range
0.3.0 doesn’t exist in NPM
which version do you really want to use?
oh you said 0.9.4 above
what is profile.clj?
so it works for me with current master
trying with 1.9.908
works for me with 1.9.908 too
;; build.clj
(require '[cljs.build.api :as b])
(b/build "src"
{:output-dir "out"
:asset-path "/out"
:output-to "out/main.js"
:main 'foo.core
:npm-deps {:react-date-range "0.9.4"
:react "15.6.1"
:react-dom "15.6.1"}
:install-deps true
:optimizations :none
:verbose true})
;; foo/core.cljs
(ns foo.core
(:require react
react-dom
react-date-range))
(enable-console-print!)
(println "hi" react-date-range)
and I’m running the above with java -cp cljs.jar:src clojure.main build.clj
hope that helps
sorry I’m not going to look at a lein
thing
all I’m interested in is verifying all this works with the minimum amount of variables
which I did above
@anmonteiro Thanks for your help. I am gonna try directly like this and then try to incorporate some lighter build systems
@nagarajan let me know if it still doesn’t work
are there any way we can rewrite part of our js code in cljs and make it still available for the rest of the js code base?
for example, say we have a js file called 'catalogue.js' where we export its functions through export function get_product_attr(...)
would be a fun rainy day exercise for me to rewrite catalogue.js
in cljs without affecting the rest of the code base?
^i've been curious about this too - specifically if there's a way to compile up a cljs project and publish to npm for consumption by a JS project
i want to write a React component but using cljs/reagent - i want the end result to be a dev library to be consumed by a JS app, and not necessarily a standalone CLJS app compiled with optimizations
@alexdong See ^:export
described here https://clojurescript.org/reference/advanced-compilation#access-from-javascript
As long as the arguments and return values are simple enough (i.e. not persistent data structures), then JavaScript can easily call into your ClojureScript code.
This will make the code callable, hanging off of Closure "namespace" objects. It doesn't do anything with respect to the export
, module system stuff you provide in your example.
You could have catalog.js
preserve its API, but delegate to ^:export
ed ClojureScript functions for implementation
having trouble calling external library that is loaded statically. getting error Uncaught TypeError:
http://cljsjs.github.io is a community effort for externs