This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-15
Channels
- # announcements (8)
- # beginners (65)
- # calva (25)
- # cider (11)
- # clj-kondo (9)
- # cljsrn (14)
- # clojure (103)
- # clojure-europe (15)
- # clojure-greece (1)
- # clojure-italy (28)
- # clojure-nl (39)
- # clojure-spec (9)
- # clojure-uk (28)
- # clojuredesign-podcast (37)
- # clojurescript (56)
- # cursive (41)
- # data-science (10)
- # datomic (25)
- # duct (1)
- # emacs (1)
- # events (3)
- # figwheel-main (7)
- # fulcro (9)
- # graalvm (7)
- # graphql (10)
- # jobs (2)
- # nrepl (17)
- # off-topic (40)
- # quil (12)
- # reitit (11)
- # remote-jobs (5)
- # rum (2)
- # shadow-cljs (387)
- # sql (22)
- # tools-deps (8)
- # vim (26)
- # xtdb (47)
- # yada (9)
Using Reagent, how do you add an attribute such as "checked" or "readonly" to an input? Usually I would do this [:input {:attribute "value"}]
but I can't simply do {:checked}
Another related thing, whenever I precheck the checkbox it gets stuck that way and I'm unable to uncheck it. Any clue about why that could be?
Does anybody use yada library for user authentication? Fox example, i want that my view A was only accessible to a user that has a role A.
@ramon.rios Yada takes :access-control {:authentication-schemes [(check-user-role-fn)]}
.. see if this might help
Thanks @lucio
Actually I believe that for roles you'd need :authorization
rather than :authentication
..
@ramon.rios It's well covered here:
I have a very simple ClojureScript Electron app (compiled via Figwheel Main) which is working fine when I use none or simple optimizations, but fails with TypeError: Cannot read property 'dc' of undefined
when I compile with advanced optimizations. Any suggestions for how to debug what might be causing this?
Are you using any 3rd party libraries, especially 3rd party JavaScript libs?
Right now I’m using virtually nothing (just re-frame plus whatever comes along with Electron) as I’m just trying to get a base to start from.
Interesting :thinking_face: So probably there’s some bundled JS with Electron itself. Are you building from the cljs-electron base, or rolling your own? (https://github.com/Gonzih/cljs-electron)
I’m using the pre-built Electron. This is my package.json
:
{
"name": "opentrack",
"version": "0.1.0",
"main": "resources/node/app/app-main.js",
"scripts": {
"start": "electron ."
},
"devDependencies": {
"electron": "^6.0.11"
},
"dependencies": {
"ws": "^7.1.2"
}
}
(about as simple as it can be!)
That looks different from the cljs-electron lib, you might want to check it out.
@paulbutcher Adding :infer-externs true
should might fix the issue
Hmm - I’ll take a look. I’m trying to get something up and running with Figwheel Main though…
Ah - thanks Lu - I’ll give that a go.
(what does infer-externs
do?)
It creates inferred_externs.js
with all the symbols that the compiler is not supposed to chunk under optimization advanced
In your cljs code you might need to add a tag ^js to what you want to be preserved.. i.e. (defn my-func [^js x] ...)
Hmm - I’m still getting the same error with :infer-externs true
😞
How do I know what I want to be preserved? I’ve no idea what bc
started out as referring to?
But add it to what?
I am afraid you have to guess by commenting out some code.. but logically if you're using some javascript interop I would naturally look at that and see what javascript functions/objects you are using
I have virtually no code! The entirety of my app (it’s the app that’s causing the problem not the renderer) is:
(ns opentrack.app.core
(:require [cljs.nodejs :as nodejs]))
(def Electron (nodejs/require "electron"))
(def BrowserWindow (.-BrowserWindow Electron))
(def app (.-app Electron))
(defonce win (atom nil))
(defn create-window []
(reset! win (BrowserWindow. (clj->js {:webPreferences {:nodeIntegration true}})))
; (.openDevTools (.-webContents @win))
(.loadFile @win "resources/index.html"))
(.on app "ready" create-window)
That’s it - there’s no other code whatsoever.
I’m guessing you need an externs file for Electron
You’ve got me curious, I’m going to pull down the latest cljs-electron and see if that has any issues building with advanced compilation turned on.
I’ve not tried cljs-electron. Like I said - I’m trying to get Figwheel Main working (and it’s working brilliantly with either none
or simple
optimizations)
But I guess it’s an interesting counterpoint!
Well, to see whether it's electron comment out everything but Electron
and BrowserWindow
variables.. if it still complains you are certain it's electron
I’ve just pulled cljs-electron and it does seem to work OK with advanced optimizations.
I guess I’ll see if I can move that across to Figwheel Main successfully, and will probably learn something (whether it has the same problem or not!)
@lucio, @manutter51 - so that was informative and I can now make my code work. But I’m not entirely sure I understand why (I would appreciate your thoughts!). Here’s my modified (and now working) code:
(ns opentrack.app.core)
; (:require [cljs.nodejs :as nodejs]))
(def Electron (js/require "electron"))
(def BrowserWindow (.-BrowserWindow Electron))
(def app (.-app Electron))
(defonce win (atom nil))
(defn create-window []
(reset! win (BrowserWindow. (clj->js {:webPreferences {:nodeIntegration true}})))
; (.openDevTools (.-webContents @win))
(.loadFile ^js/electron.BrowserWindow @win "resources/index.html"))
(.on app "ready" create-window)
The two changes are switching from (nodejs/require ...)
to (js/require ...)
, and adding ^js/electron.BrowserWindow
I think I understand why the ^js/electron.BrowserWindow
is necessary, but I’ve no idea why nodejs/require
doesn’t work but js/require
does?
Hi all, are there any noteworthy libraries for dom
manipulation that do not rely on react?
if you still want functional dom, https://github.com/cjohansen/dumdom relies on snabbdom instead
From my understanding js/
is the way you can access external libraries. In other words, the global variables of the library you are importing are all available under js/
Indeed - I understand that. But why doesn’t cljs.nodejs/require
work? It’s part of the ClojureScript API:
https://cljs.github.io/api/cljs.nodejs/require
Hi there, I have advanced compilation turned on for production build so I'm in the process of switching over dot property access to use gobj/get
. However, I'm running into the following error:
(let [map ((gobj/get map-ref "getMap"))]
(js/console.log (gobj/get map "addLayer")) ; logs a function as expected
((gobj/get map "addLayer") tile-src) ; error: cannot read property "addLayer" of undefined. This should be invoking the method that is logged in the line directly above
(.addLayer map tile-src)) ; this works fine
Am I blind here?
clj -A:fig:build 5.5m Tue Oct 15 18:24:24 2019
Error building classpath. Could not transfer artifact com.bhauman:figwheel-main:jar:0.2.3 from/to clojars ( ): Range Not Satisfiable (416)
Why?
https://clojars.org/com.bhauman/figwheel-main
com.bhauman/figwheel-main {:mvn/version "0.2.3"}
Do I have any mistake here?@kwladyka 416 is a http status code for partial downloads. maybe you have a half-aborted file sitting in ~/.m2
?
rm -r ~/.m2/repository/com/bhauman/figwheel-main/0.2.3
solved the issue. Thank you. Like always 🙂
Is there a defacto library to use in CLJS for webworkers?