This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-09
Channels
- # announcements (16)
- # beginners (86)
- # calva (4)
- # cider (17)
- # circleci (1)
- # clj-kondo (4)
- # cljs-dev (12)
- # cljsrn (4)
- # clojure (82)
- # clojure-europe (2)
- # clojure-houston (4)
- # clojure-italy (5)
- # clojure-nl (7)
- # clojure-spec (49)
- # clojure-uk (19)
- # clojurescript (76)
- # core-async (7)
- # cursive (1)
- # data-science (4)
- # datomic (5)
- # figwheel (1)
- # fulcro (10)
- # graalvm (15)
- # jobs (1)
- # juxt (6)
- # kaocha (2)
- # leiningen (5)
- # random (2)
- # shadow-cljs (25)
- # sql (5)
- # tools-deps (113)
- # vim (3)
- # yada (14)
Hey, everyone. Is there anyone used the react navigation as a clojurescript format? It's really confused for me to write it, when the react class component used. For example:
class HomeScreen extends React.Component {
static navigationOptions = {
title: 'Home',
headerStyle: {
backgroundColor: '#f4511e',
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
};
render() {
return ...
};
}
I want get some hints about it...existing export isn't about JS modules btw, it about preserving an api through advanced compilation
I am hoping to do something like this:
https://babeljs.io/en/repl#?babili=false&browsers=&build=&builtIns=false&spec=false&loose=false&code_lz=KYDwDg9gTgLgBAMwK4DsDGMCWEVwCYQDKEAtsDABaYoDmAFCAJRwDeAUHHFOUlLiHABUcAcJABuNgF82bUJFj5gCAIZIANvGTosOOCRUBrYA2btO3GL35CRtidKA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=es2015%2Creact%2Cstage-2&prettier=false&targets=&version=7.5.5&externalPlugins=
At the moment my understanding is that it is possible to do
(defn ^:export doSomething [...])
but not something for make
as above
@godwin.ko it's really the only proper way - anything else breaks caching if you're not careful
not sure if I can insert code that run during compile time and read an edn config in order to get deployment specific environments?
@nha we don't really support ES6 stuff (from ClojureScript itself), you should just write some JS if you need to do that for JS consumers
Something like that you mean? (untested)
(js/Object.defineProperty js/exports
"__esModule"
#js {
:value true
}
)
(js/goog.exportSymbol "exports.default" make)
Or just writing it in JS with the JS toolchain etc?yes use JS tooling - we have some support for ES6 modules but it's not very active and I don't know how much we've look at the export side of things
honestly the only real interest we've had wrt. ES6, is allowing you to write ES6 libs that are Closure aware so they can be a part of your build
Is there a way in ClojureScript to call a function defined as private, in another namespace, without a warning that it is private? Not a big deal if there isn't -- just curious.
@andy.fingerhut you should be able to use the var pattern from Clojure
Thx. Will give that a try. I guess I assumed it would not work, given difference in Vars in ClojureScript. Should have gone that extra step before asking.
One small thing to be aware of, if it is critical to you, is the use of a Var causes a little generated code bloat.
I'm learning clojurescript. Coming from backend compiled language, can someone recommend some readings / approaches on ways to avoid runtime exceptions. Even typos are harder to spot in dynamic languages. Thanks.
In dynamic languages compile time checking can be replaced by runtime testing 🙂. Maybe spec
and test.check
are what you need? https://clojure.org/guides/spec
For me it's combination of (from most used to less): - thinking about all possible valid inputs (with testing them e.g. via repl) - writing tests (often I copy my previous tries from the repl and add a few more cases) - spec + test.check (I don't use it that often, I'd like to use it more) As for detecting typos early, in browser figwheel tells me about many typos during reload (https://figwheel.org/). I use 2 screens - one I am developing at and second where I have opened browser. For node, I have the output hidden, but it also tells you in console when some namespace couldn't be reloaded because of some typo.
Thanks both. More tests then. Maybe it's a mentality change for me too. I'm using shadow-cljs. I'll also take a look at figwheel.
Perhaps looking at some videos with the title repl driven development
might help. What is quite nice is testing in the repl until you are basically happy with a function, then converting some of those repl executions into tests.
thanks, I'll do
just on the topic, with real driven dev
how is it going to work with "largish" refactoring?
Possibly large refactoring is more difficult to do with a dynamic language. There are a lot of tools with a typed language which will be able to automate renaming, extracting functions, and things like that. As far as I'm aware there are no such tools for clojure to do this.
I tried with-redefs attempting to temporarily reassign the value of function into
(or perhaps it was some other function in cljs.core), and it seems not to have taken effect. Is this known limitation of ClojureScript with-redefs?
Hmmm. Let me see if I can repro.
@andy.fingerhut oh I know - ClojureScript direct links the standard lib
Like this: https://gist.github.com/jafingerhut/63a17a7b9562237954cf4be62bb9fae4
In the case of the test where I wanted to with-redefs on a function in cljs.core, it was straightforward for me to work around this by calling my own function my-vector instead of vector, and do (def my-vector vector)
, the code that called my-vector
, then with-redefs
to temporarily change the definition of my-vector
So this sounds like a similar kind of direct linking that exists for Clojure, then. Makes sense.
This kind of with-redefs does work for Clojure, though, at least for calls from user code to core fns. So perhaps ClojureScript has one extra 'level' of direct links in the user's code?
Yeah, just double-checked. The same example in my gist linked above works differently with Clojure/Java, I think because Clojure's direct linking only applies to calls between functions in core, unless you explicitly compile your own code with direct linking enabled, too.
if you think so, I'm happy to do that. Also perfectly content if the resolution is only a caveat in the docs somewhere.
does it actually start an honest-to-goodness socket REPL in the JS process? or does it rely on a socket repl being started in the JVM compiler process and then does something like piggieback?
and even if most uses is of the latter piggyback style, is there any “native” support for prepl in CLJS where I could bridge it over websockets or some other protocol?
I don't know about prepl. I recently started using ClojureScript with a Node-based socket REPL, and did some experiments to note that starting the JVM process does not also create a node process until and unless some TCP client connects to the socket REPL TCP port. Then it fires up a new node process.
From that I am inferring that the TCP connection is going to the JVM process, not the node process.
I am hoping there’s some sort of prepl machinery in CLJS as well, where I could build a bridge over websockets or browser messaging protocols to do repl-y things
@lilactown Hi there! Just a small shout-out to thank you for hx
! It saves me a lot of troubles when working with third-party libraries relying on react hooks 🙂
I really do and I feel like I have much less edges to work around than with reagent. The only workaround I see coming is the integration with re-frame but I remember seeing some demo of yours which I can adapt so that should be fine 🙂
Yeah, the global state management story with the latest React is a bit rough. A nice integration with re-frame would be really cool but atm re-frame brings in reagent with it and is coupled to it in a few places
there are some benefits that re-frame gets by using reagent’s Reaction directly. in an ideal world, the whole RAtom / Reaction would be separate from reagent, the UI lib
Well, I guess for now the adaption of the RAtom to a useState hook should work good enough (I hope). I'll see soon
my use case is that I am building a dev tool that listens to tap>
and interacts with the CLJS process directly. atm I’ve built it with a specific protocol over websockets / Chrome APIs for the exact interactions I need with the user’s runtime state, but I am quickly building just another REPL protocol
how do i check if my code is running is nodejs or a browser?
I was thinking
(exists? js/window)
@currentoor I'd maybe opt for (and (exists? process) (not (empty? (.-version process))))
@alpox i think mean (and (exists? js/process) (not (empty? (.-version js/process))))
?
and yes i like that better, js/window
can be set when someone tries to write compatible code, this is less likely to accidentally get stomped on
thank you