Fork me on GitHub
#clojurescript
<
2019-10-15
>
vinurs05:10:57

does cljs-http can used for react-native?

Risetto08:10:25

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}

hkjels08:10:19

[:input {:checked “checked”}]

Risetto08:10:48

Ah okey, that's how I'm doing it now

hkjels08:10:05

actually any non false value I believe

Risetto08:10:17

Alright cool, maybe true would look better 🙂 thanks!

hkjels08:10:08

your welcome 🙂

Risetto08:10:23

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?

Risetto08:10:45

Turns out I should use :defaultChecked instead 🙂

Ramon Rios09:10:44

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.

Lu11:10:39

@ramon.rios Yada takes :access-control {:authentication-schemes [(check-user-role-fn)]}.. see if this might help

Lu11:10:25

Actually I believe that for roles you'd need :authorization rather than :authentication ..

Lu11:10:51

@ramon.rios It's well covered here:

paulbutcher12:10:05

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?

manutter5112:10:21

Are you using any 3rd party libraries, especially 3rd party JavaScript libs?

paulbutcher12:10:13

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.

manutter5112:10:13

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)

paulbutcher12:10:14

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"
  }
}

paulbutcher12:10:27

(about as simple as it can be!)

manutter5112:10:51

That looks different from the cljs-electron lib, you might want to check it out.

Lu12:10:22

@paulbutcher Adding :infer-externs true should might fix the issue

paulbutcher12:10:28

Hmm - I’ll take a look. I’m trying to get something up and running with Figwheel Main though…

paulbutcher12:10:00

Ah - thanks Lu - I’ll give that a go.

paulbutcher12:10:07

(what does infer-externs do?)

Lu12:10:05

It creates inferred_externs.js with all the symbols that the compiler is not supposed to chunk under optimization advanced

Lu12:10:20

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] ...)

paulbutcher12:10:21

Hmm - I’m still getting the same error with :infer-externs true 😞

Lu12:10:42

Add the ^js

paulbutcher12:10:43

How do I know what I want to be preserved? I’ve no idea what bc started out as referring to?

paulbutcher12:10:50

But add it to what?

Lu12:10:29

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

paulbutcher12:10:44

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)

paulbutcher12:10:53

That’s it - there’s no other code whatsoever.

manutter5112:10:33

I’m guessing you need an externs file for Electron

manutter5112:10:38

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.

paulbutcher12:10:40

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)

paulbutcher12:10:59

But I guess it’s an interesting counterpoint!

Lu12:10:04

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

paulbutcher12:10:28

I’ve just pulled cljs-electron and it does seem to work OK with advanced optimizations.

paulbutcher12:10:04

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!)

paulbutcher13:10:42

@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)

paulbutcher13:10:31

The two changes are switching from (nodejs/require ...) to (js/require ...), and adding ^js/electron.BrowserWindow

paulbutcher13:10:24

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?

Adrian13:10:50

Hi all, are there any noteworthy libraries for dom manipulation that do not rely on react?

uosl08:10:25

if you still want functional dom, https://github.com/cjohansen/dumdom relies on snabbdom instead

Adrian11:10:16

Thank you!

👍 4
Lu14:10:10

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/

paulbutcher14:10:00

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

Alex15:10:32

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

kwladyka16:10:08

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?

thheller16:10:04

@kwladyka 416 is a http status code for partial downloads. maybe you have a half-aborted file sitting in ~/.m2?

thheller16:10:39

check ~/.m2/repository/com/bhauman/figwheel-main

🍻 4
kwladyka16:10:04

rm -r ~/.m2/repository/com/bhauman/figwheel-main/0.2.3 solved the issue. Thank you. Like always 🙂

👍 4
David Pham17:10:39

Is there a defacto library to use in CLJS for webworkers?