This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-30
Channels
- # announcements (3)
- # aws (5)
- # beginners (71)
- # boot (7)
- # calva (74)
- # cider (6)
- # clj-kondo (2)
- # cljs-dev (5)
- # clojars (6)
- # clojure (84)
- # clojure-dev (7)
- # clojure-europe (1)
- # clojure-italy (23)
- # clojure-nl (43)
- # clojure-sanfrancisco (1)
- # clojure-spec (4)
- # clojure-uk (173)
- # clojurebridge (1)
- # clojurescript (14)
- # cursive (44)
- # datomic (9)
- # duct (2)
- # emacs (2)
- # fulcro (4)
- # graalvm (4)
- # graphql (27)
- # hoplon (6)
- # keechma (50)
- # off-topic (3)
- # other-languages (8)
- # pathom (2)
- # pedestal (14)
- # planck (5)
- # re-frame (3)
- # reitit (6)
- # ring (2)
- # robots (2)
- # spacemacs (9)
- # tools-deps (15)
- # vim (44)
in a component like this - <Rect filters={[Konva.Filters.Noise]} noise={1} x={10} y={10} width={50} height={50} fill={this.state.color} shadowBlur={10} ref={node => { this.rect = node; }} onClick={this.handleClick} />
@jcb You should be able to do -> Konva .-Filters .-Noise
or (.-Noise (.-Filters Konva))
. The .-
allows you to "get" a property off a JS object
also the single element in curly braces { thing }
syntax in js ES6 expands to {thing: thing}
oh wiat, that's not relevant here
the {}
here are representing code within JSX I think
yes, it would be:
{:filters #js [(.. Konva -filters -noise)]
:noise 1
:x 10
:y 10
...
}
thanks for the replies, I don't think I gave enough context. It seems to be a namespace? I've not seen this syntax before. whole example can be found here - https://konvajs.org/docs/react/Filters.html
docs here - https://konvajs.org/api/Konva.Filters.html if anyone's interested
does the code @lilactown gave not work? I'd have thought it would
afaik js doesn't really have namespaces, just objects, so you'd access the members just like accessing an object property
@jcb have you got a repl available?
if you've got a repl available you can kind of figure out where things are going wrong - so is Konva defined? If so, log it to the repl (js/console.dir Konva)
then see if you can access the properties etc
thanks for the tip @danieleneal
So in node modules filters are available in konva/lib/filters in the same way shapes are in konva/lib/shapes. so [react-konva :refer [Rect]] makes rect useable as [:> Rect {etc}] however examining (js/console.dir react-konva) only lists shapes and setup (eg stage etc) functions not the filters. I've had unresolvable problems like this in the past when dealing with esModule exported libraries
(:require [react-konva :refer [Stage Layer Rect]] in the initial ns require along with reagent etc
as in the example I linked above - the filter functions aren't mentioned until the component
import React, { Component } from 'react';
import Konva from 'konva';
import { render } from 'react-dom';
import { Stage, Layer, Rect } from 'react-konva';
so assuming you have something like:
(ns my-app.core
(:require ["react-konva" :refer [Stage Layer Rect]]
["konva" :default konva]))
you should be able to log Konva.Filters.Noise
:
(js/console.log (.-Noise konva/Filters))
you might have to play with the import of "konva"
- I’m not sure if it should be :default
or :as
if you import it like:
["konva" :as konva]
and log it, and it looks like:
{"default": ...}
then you should use :default
instead
When using swap!
(or anything else that requires a function) but I want to always return the same value, should I use constantly
?
i.e.:
(swap! foo update :bar (constantly 42))
Bad example, as it's not swap!
but update
that requires the function, but the idea is the same
If I know I’m always going to want to put the same constant value there, I’d just use assoc
instead of update
.
Hi all, I'm stuck, certainly lost (I'm a noob in this ecosystem) I have a SPA with CLJS and now I'm trying to migrate de backend from nodejs to clj, well I chose luminous, for testing (No sure if the parameters produces a good result hahaha) lein new luminus myapp +sqlite +cljs +re-frame +swagger +service +auth -> lein run runs the clj part, Question, how do I run/load the front/cljs part?
by connecting a browser to the port it opens
if you add figwheel to the project, you can connect an interactive cljs repl in a terminal to the app in the browser
Will it run independently? different port front and back
what does that even mean?
if you write your webserver to only load static files, you can host it from a test server without running the back end, if that's what you mean
I understand what you mean, in this case i'm looking for, I think it's possible, using the CLJ make accessible the CLJS code from "browser"
(.launch O (into-array String args))
where O is the object with a launch method
and args is some sequential
I was using clojure.set/difference
on somewhat large sets (around 10k items) and the performance was noticeable, so I modified it to use transients.
Is there a reason why clojure.set
doesn't use transients in the first place? Lower performance for small sets or something like that? Or is it purely for philosophical reasons , "don't use transients unless you really need them"?
@noisesmith thanks
@dromar56 it could be as simple as clojure.set being older than transients, and nobody doing the work to make it use them
maybe that's overstating things
Thanks, I wanted to be sure there wasn't a downside to transients I hadn't taken into account. I could do something more optimized than set operations, but for now with the use of transients is fast enough
@dromar56 also, since this is is #beginners I should point out that there's a common newbie error of using transients but not using the return values of transient ops, which risks dropping data on the floor
always use the return values of transient conj!
etc. just like you would with a normal immutable
I would expect that modifying clojure.set functions to use transients very well might make them a little bit slow when invoked on small sets. I haven't measured that recently.