This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-22
Channels
- # announcements (3)
- # beginners (22)
- # braveandtrue (6)
- # calva (2)
- # cider (85)
- # cljdoc (1)
- # cljs-dev (21)
- # cljsrn (2)
- # clojure (70)
- # clojure-italy (9)
- # clojure-spec (1)
- # clojure-uk (144)
- # clojure-ukraine (6)
- # clojurescript (109)
- # cursive (59)
- # data-science (15)
- # datomic (40)
- # emacs (8)
- # fulcro (64)
- # funcool (8)
- # graphql (8)
- # hispano (3)
- # hoplon (7)
- # jobs-discuss (29)
- # leiningen (3)
- # luminus (2)
- # off-topic (13)
- # onyx (9)
- # parinfer (49)
- # pedestal (2)
- # portkey (8)
- # re-frame (10)
- # reagent (33)
- # reitit (13)
- # ring (2)
- # ring-swagger (16)
- # shadow-cljs (193)
- # spacemacs (1)
- # sql (19)
- # tools-deps (19)
I just started looking into core.async
for clojurescript. Under which conditions would one opt for core.async
over js async/await
or promises
? A use case I am thinking about is a basic http request. Most articles I am reading are written before the mechanisms were part of JS, so I am curious when core.async
is the right tool.
@tkjone core.async
brings a whole world of complexity that you almost certainly don’t need. I’d strongly recommend you stick with promises unless you have a clear need otherwise. Promises are reasonably ergonomic to work with in cljs, particularly with the alet
macro from the promesa
library
This is my understanding as well. Thank you for confirming. I am looking at both and just couldn't seem to see, for basic front end server requests, why go blocks would be needed
Yes exactly. And they are actually worse, because they don’t deal with exceptions well and they produce a massive stack trace of generated code. For this reason, I avoid core.async
-based libraries like cljs-http
in favor of promise based libraries
I think I would suggest pretty much exactly the opposite. core.async in most use cases is trivial to set up and use and extremely transparent. And it pretty much just works without having to think about it. The model is higher level than promises and callbacks.
So, if you aren't already using promises and such (you aren't going into some legacy code), I would (and do) opt for core.async
If you are curious, it is stuff like this that makes me shy away from core.async: https://github.com/r0man/cljs-http/issues/110
The exception handling on the producer side just isn’t well thought through. https://dev.clojure.org/jira/browse/ASYNC-73
Thanks. Never had an issue with this - but then I don't do that sort of thing in go blocks. Even if that worked (could be made to work) I still wouldn't use that idiom. Much better to use error channel(s) and/or <?. And as a general rule, it is always a good idea to avoid exception style code as much as reasonable (or at least hide it as in the mentioned idioms)
can’t fix it if it’s in a library. hard to control what might throw in javascript. all kinds of crap can throw unexpectedly. again, i’m just not sure what you get given how much work it is
Hi there, I've got a reagent/re-frame app in which I get React from cljsjs. Now I want to use a npm package that depends on React and when try to compile I get the error "Error: Can't resolve 'react' in '<PROJEC_HOME>/node_modules/react-select/dist'" Should I also include react as a npm dep?
Have you seen this tut? https://github.com/magomimmo/modern-cljs/blob/master/doc/second-edition/tutorial-21.md#your-first-react-component
Also, you may want to ask your question on the #reagent channel
or #re-frame
Thank you for your help. I posted the question here because I thought it was a npm-deps related issue.
Is anyone in here running their ClojureScript on ChakraCore (instead of V8)?
On startup, does cljs ignore files that are already compiled, or does it compile everything from scratch each time?
On startup, does cljs ignore files that are already compiled, or does it compile everything from scratch each time? [2]
@loganpowell FWIW, ClojureScript’s unit test suite includes ChakraCore.
@mfikes! I saw your YouTube video testing ChakraCore. Thanks for responding. Is it safe for me to replace my Node VM with CC?
I'm running into a v8 limit with JSON.stringify
atm 😄
At least as far as ClojureScript’s behavior on ChakraCore, we’ve been (successfully) testing with it for quite a while now.
Is there a specific set of Node and CC versions I should pair together?
FWIW, when ClojureScript is tested with ChakraCore, it is not done with Node-ChackaCore. https://github.com/nodejs/node-chakracore We instead use Microsoft binaries from https://github.com/microsoft/chakracore
Ah, so not ready for Node replacement yet
I wouldn’t conclude that. Node-ChakraCore’s quality likely surrounds how well they integrate the two.
(Even if you ran ClojureScript’s unit tests on Node-ChakraCore, ClojureScript’s unit tests focus on the JavaScript implementation. It never invokes anything that would be in Node.)
Have you tried the node-chakracore
setup?
No worries. If I can't figure out another (potentially hackier) solution, I'll give it a go and let you know
Let me check that out
@tkjone The following link might help you. https://groups.google.com/d/msg/clojurescript/LBy0yiZiWrA/vd1TYeD-AwAJ
Has anyone run into an issue with the warning-handlers
compiler option as passed in thru project.clj via lein cljsbuild? It looks like with the current version of cljsbuild, the custom warning handler feature always throws an exception: https://github.com/emezeske/lein-cljsbuild/issues/494
Hi ! Is someone familiar with this doc ? https://clojurescript.org/guides/webpack I’m trying to follow “Using Your Foreign Library” with lein and figwheel and I think I understood a lot.. But my browser still displays lot of errors like: goog.require could not find: module$Users$<my_absolute_path_to_my_project>$node_modules$create_react_class$index . I’m trying to include npm modules since yersterday and had so much problems doing it... 😕
Same problem here... From what I understand, this solution seems to be the simplest one: https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules . Please tell me if it works for you 😉
@julien.fleury check https://github.com/pesterhazy/presumably/blob/master/posts/double-bundle.md and https://github.com/pesterhazy/double-bundle
Yep, that was one of my first shots, but after testing it, it seems to be outdated 😕
hey everyone. i’m looking for some great projects using cljs / figwheel for node applications to read through and learn from. any recommendations? the larger the better.
@julien.fleury outdated how?
Mmm, just solved the problem I had with it, it doesn’t seem to come from the versions of the libs, as I first thought. I had to add ” :jvm-opts [“--add-modules” “java.xml.bind”] ” to project.clj . I will send that in an issue. But I think there are other problems after that, when updating to newer versions of reagent, clojure etc. I will check now that I have solved this first step.
Well, I confirm that another problem pops when you pass from reagent 0.6.0 to 0.8.1 / update React from 15 to 16. Apparently, people at Reagent seems to be aware of it, from this comment in the code: https://github.com/reagent-project/reagent/blob/master/examples/material-ui/project.clj 😕
you can make it work with reagent 0.8.1 as well I think
I would definitely love to know how 😕 Taking the double bundle, updating clojure/clojurescript and reagent from 0.6.0 to 0.8.1 and then js dependencies to last ones ( “@cljs-oss/module-deps”: “^1.1.1", “moment”: “^2.22.2", “react”: “16.4.2", “react-dom”: “16.4.2", “react-datetime”: “^2.15.0" ) I get only this message in my browser: Error: Undefined nameToPath for react
Figwheel doesn’t seem to have any problem on its side 😕 I have no clue where to go next
From what I understand, it’s reagent searching for react via goog.require, but React & ReactDOM are well defined in my browser
Well, if someone wants to give it a try: https://github.com/pesterhazy/double-bundle/issues/2
Finally found how to make it work with :foreign-libs ! 🙂
@julien.fleury glad you got it to work
I'm happy to incorporate your changes into the double-bundle repo
Re: the --add-modules
flag, that sucks that lein hasn't learned to deal with that on its own yet
Re: foreign-libs, yes I use that technique now as well. Basically, include the webpack-built bundle as a foreign lib. It's necessary for unit testing using lein doo, for example
this could be cool https://amphtml.wordpress.com/2018/08/21/workerdom/
Sounds similar to https://github.com/AshleyScirra/via.js
But they essentially queue up actions on the proxied dom object and I don't think it'll work with things that are supposed to return results synchronously.
If you want to retrieve a value from the DOM, it must be accessed asynchronously, since it requires a postMessage round-trip. Via.js provides a global get() function which returns a promise that resolves with the requested DOM property value, e.g.:
With using SharedArrayBuffers though, and blocking, values retrieved from the dom could be converted back into synchronous operations.
Or maybe not. You could possibly forward your mutation over to the main thread and work on the non-serializable object there. But that sorta defeats the purpose of moving stuff off the main thread.
I don't think it makes much sense in the context of react and such that already batch create dom nodes and can do so async (react v16)
I've heard it can help performance in some situations to move the react renderer into a worker, for the reconciliation crunching
in theory you could do all react ops in a worker and just transfer its patch set over
But the blog post you linked said the thing works with react. So maybe you'll get that all for free?
wondering how to open a new window in the browser, window.open()
did not seem to work
window.open
is typically blocked by browsers due to ads. you can only open them under specific conditions
would there be a way to open the window on button click, then pipe the data url to it once it's done?
@restenb you could do it asynchronously using postMessage and window.opener: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
i've noticed a lot of cljs code uses native js code instead of their google closure equivalents for stuff like dom/js object manipulation etc. I have noticed the goog versions being slightly slower in some quick benchmarks, but presumably this is due to adding things that are usually justifiable ie browser compatibility. Is there a particular reason for this preference of native js? Is it perception of raw js being "simpler", or closure being unnecessary? non-awareness of the goog stuff? Anything else?
so yeah lots of the stuff in there isn't really that relevant anymore since browser support is a little bit more sane these days (although still not good)
They never updated the UI stuff around the material design and some of it appears old now, like look at the editor: https://google.github.io/closure-library/source/closure/goog/demos/editor/editor.html
my guess is that those are meant to play well with react, so there are mostly useless for clourescript
material components are being designed to be compatible with closure advanced compile: https://github.com/material-components/material-components-web/blob/master/docs/closure-compiler.md
its sometimes not clear what google does internally. sometimes it feels like half of their own developers never even heard of the closure compiler.
anyone know of any reason i wouldn’t be able to require core.async in a .cljc
file that defines macros?
I personally have no idea. But I suspect your answer may be found in this direction: https://github.com/cgrand/macrovich
Using :foreign-libs
and the babel-standalone transformation, I'm compiling alongside from React JSX. This works, but not if there are any import
statements within the JSX. Example:
import React from 'react'; // causes goog.require could not find: module$react
export default class Desktop extends React.Component {
render() { return (<div>"Desktop!"</div>); }
};
Is there any way this can work, or should I have a custom transformation which removes imports?> You may have noticed that our ES6 file does not declare its dependency on React, ReactDOM, or ReactDOMServer via import. Handling this correctly depends on a pending patch to Google Closure to support Node.js module resolution for ES6 source files. When this change lands this guide will updated. https://clojurescript.org/guides/javascript-modules Does anyone have a link to this issue?
bidi leaves the user to handle fragments themselves, right?
cljs.user> (def my-routes ["#/" {"index.html" :index
"article.html" :article}])
#'cljs.user/my-routes
cljs.user> (b/path-for my-routes :index)
"#/index.html"
cljs.user> (b/match-route my-routes "#/index.html")
nil