This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-06
Channels
- # aleph (15)
- # beginners (40)
- # boot (14)
- # cider (90)
- # cljs-dev (132)
- # cljsrn (25)
- # clojars (7)
- # clojure (188)
- # clojure-chicago (4)
- # clojure-dusseldorf (1)
- # clojure-greece (9)
- # clojure-italy (43)
- # clojure-russia (16)
- # clojure-sg (7)
- # clojure-spec (39)
- # clojure-uk (81)
- # clojurescript (170)
- # component (5)
- # core-async (7)
- # cursive (49)
- # data-science (65)
- # datascript (3)
- # datomic (27)
- # graphql (3)
- # hoplon (4)
- # instaparse (56)
- # klipse (129)
- # leiningen (1)
- # lumo (28)
- # off-topic (4)
- # om (15)
- # onyx (54)
- # overtone (7)
- # pedestal (7)
- # re-frame (9)
- # reagent (72)
- # ring (33)
- # ring-swagger (2)
- # spacemacs (1)
- # untangled (19)
- # vim (2)
- # yada (12)
foreign-libs - order of execution. Is there a way to ensure my js foreign-lib is loaded before the rest of my dependencies?
I've submitted a PR for "surrogate" packages that supply faux namespaces for cljsjs.react, cljsjs.react.dom and cljs.react.dom.server. This could reduce the headaches of using reagent (and other wrappers) with a provided version of React (e.g. in a separate webpack-built bundle): https://github.com/cljsjs/packages/pull/1192
This may help with issue people have had, e.g. @reefersleep's empty-namespace problem yesterday
@tomerweller there’s no way to control beyond the namespace dependency graph
@dnolen, say that I want to use my own version of react but I need to load before reagent, any way to make that happen?
@tomerweller thanks for http://blob.tomerweller.com/reagent-import-react-components-from-npm by the way
(using foreign-lib, that is)
@tomerweller you need to make your own React foreign lib then
@pesterhazy, Thanks 🙂 It’s been getting a lot more traffic than I expected
Can it provide multiple namespaces?
(In the case of a bundle, for example)
dnolen: do you have a spec for :compiler-options
? @U072WS7PE was asking about spec improving tooling, jogged my mind
@tomerweller, I spend a day writing out a blog post (https://github.com/pesterhazy/presumably/blob/master/posts/double-bundle.md) then found your post, which is similar, in an almost uncanny way
Except one year before me 🙂
Looks good. There’s enough curiosity in this space for more resources 🙂
Hey y'all! I am confused by some code I wrote on Thursday and of which I think it worked then, but now it doesn't:
(go-loop []
(let [{:keys [type bytes-sent bytes-total response] :as x} (<! channel)]
(when (= :progress type)
(dispatch [:something uid (/ (float bytes-sent) bytes-total)]))
(when (= :success type)
(dispatch [:something-else])))
(recur))
I get can't recur here
. But recur is the last expression of the go-loop
:thinking_face:I’m revisiting this right now, might add an update with the foreign-libs options.
@igel, is there a reason your recur
happens outside the let
? I don't think this could cause the error but I'm curious
I also tried to move it in, same error. It's outside because it's independent of what happens inside the let
Can you move the bindings from the let
into the bindings for the go-loop
? They're both binding forms, right?
After unstashing the changes, the go-loop
macro wasn't required anymore. Don't get why it was lost
Hahaha oops :thumbsup:
@igel I made this, it works:
(def channel (chan))
(reg-event-fx :foo
(fn [_ _]
(println “foo”)))
(reg-event-fx :bar
(fn [_ _]
(println “bar”)))
(go-loop []
(let [x (<! channel)]
(when (odd? x) (dispatch [:foo]))
(when (even? x) (dispatch [:bar])))
(recur))
(put! channel (rand-int 10))
Tested in http://app.klipse.tech/ 🙂
@dnolen Thanks, That was very helpful.
I’m now looking at :npm-deps
. Is there a way to have these provide namespace(s)?
@tomerweller nope not possible - Google Closure controls the naming there
this is pretty interesting https://twitter.com/a_dixon/status/872116546918793216
Wow, that's awesome.
A lot of JavaScript front-end is criticized for chasing the next new hotness
ClojureScript seems to have the same rapid pace, but every new hotness is really flippin' sweet
I was sort of visualizing something like this and hoping to try it 😮 eavt fact db plus additive rule engine
@roberto This is the headline, buried in the Readme (although it's not implemented yet, it's the basic idea): >Using a rule engine allows us to know exactly what changes from one state to the next. This means we don't need React's diff algorithm or the concept of subscriptions. If we declare views as the consequences of rules, we can automatically point update them when the facts they care about change.
It does say it wraps Clara in the Readme.
I'm using a JS library, that has a funky constructor sequence: new Chart(ctx).Doughnut(data,option); I'm having trouble constructing this Doughnut object in cljs. What is the best way to do something like this?
yea, that's basically what I have, but I get errors whenever I try to make the doughnut 😞
The docs on the JS lib aren't that great, and I'm not a JS expert so its a little hard to tell from the source code
Maybe Doughnut is like a method on Chart.prototype?
Like, the equivalent of a static method on the Chart class, rather than something a Chart instance has
@roberto Seems like, insofar as it does what re-frame does... It lenses over your state db/atom and updates it in place, using a declarative rules engine.
mdb.min.js:3 Uncaught TypeError: Cannot read property 'value' of null at n.<anonymous> (http://localhost:3000/md-bootstrap/js/mdb.min.js:3:13127) at Object.n.each (http://localhost:3000/md-bootstrap/js/mdb.min.js:2:8745) at n.calculateTotal (http://localhost:3000/md-bootstrap/js/mdb.min.js:3:13086) at n.initialize (http://localhost:3000/md-bootstrap/js/mdb.min.js:3:11827) at n.i.Type (http://localhost:3000/md-bootstrap/js/mdb.min.js:2:17763) at n (http://localhost:3000/md-bootstrap/js/mdb.min.js:2:21686) at i.(anonymous function) [as Doughnut] (http://localhost:3000/md-bootstrap/js/mdb.min.js:2:21981) at etl_service$components$control_panel$draw_donut_chart (http://localhost:3000/js/out/etl_service/components/control_panel.js:67:18) at Constructor.<anonymous> (http://localhost:3000/js/out/etl_service/components/control_panel.js:77:62) at Constructor.reagent$impl$component$custom_wrapper_$_componentDidMount [as componentDidMount] (http://localhost:3000/js/out/reagent/impl/component.js:319:10)
What are you trying to read .value
of? The donut?
I'm not sure what .value is referring to, the things that are passed to the ctor are a couple of maps that I converted with clj->js
there are definitely nil vals in one of the maps, but that is what the example code showed, definitly kinda confusing when the docs and examples are lacking
from the stack trace, it looks like it is iterating over some object inside the constructor, and one of the fields in the object is nil
well, I was thinking I might have been constructing the object incorrectly, but based on what you guys are saying it looks like my original code was correct, so the problem lies somewhere else
I'm unsure why creating a session
appears to require scraping a whole namespace for rules... (session my-session 'my-ns.rules)
Am I reading that right? Why not just provide the rules as a collection?
how do i maintain a reference to a map whilst destructuring it at the esame time?
@michaellindon I think you want :as
thanks
hey quick question. I’m using selmer in a luminus generated app, and I want to serve some css that’s in a cljsjs .jar. I tried {% style "/class/path/my.css" %}
but that’s not working
eoliphant: you might want to ping @U050CBXUZ about it. I think he knows quite a bit about selmer.
I also have a quick question. I'm using a framework that, in JS, is started by calling new Komada.Client(...)
(where Komada
is just the require
d framework). How would this be done in Clojure, syntactically? I have the framework bound to Komada
. I tried ((.-Client Komada). ...)
, but that throws an error that _SLASH_
is not defined.
(js/Komada.Client. ...)
js/Komada
gives you the global JavaScript object Komada
(js/App.Object. <arguments>)
is equivalent to new App.Object(<arguments>)
Oh, okay. Thanks.
I didn't know that js
was used with more than just global built-in objects.
Oh wait
You said "the global JavaScript object Komada
"
It's not global. It's bound using let
.
I guess it'd just be (Komada.Client. ...)
then?
How are you binding it in your let?
(let [Komada (js/require "komada")
(That's the first line of my let.)
I don;t think that will work ClojureScript does not know about CommonJS require's. How are you getting Komada
into your project?
Oh, I'm using Node
I'm getting it into my project by installing it with npm
You'll want to use cljs.nodejs/require
then like so
(ns my.app
(:require [cljs.nodejs :as nodejs]))
(def Komada (nodejs/require "Komada"))
@spinningtopsofdoom that doesn’t matter, it does the same thing
@tech_hutch (new (.-Client Komada) args)
should work
@thheller Thanks for the correction, I was mistakenly recalling ClojureScript in the browser
Okay, I forgot about new
.
I have question about om.next. I see that you can provide IQuery which will be available as props to the component. Also you can pass props to child component. So what happens actually for a child component with both specified? Is it ok not to pass the props to child component with just the IQuery specified?
does anybody have any experience with sente? my client is connecting to the server just fine, and i'm setting the :uid on the session, but i can't quite figure out how to "reconnect" the websocket so that sente sees the previously anonymous connection with the new :uid
when I connect I send my uid, if I have one
and that maintains the session
(from the frontend point of view)
but since it's a single page app i'm not refreshing the page which would then have the uid on the session
oh, so you want to explicitly give them a new connection uid? I’ve never done that
I’ve only selected uid from frontend
(or just allowed a default pick from backend)
out of curiosity, do you handle authentication via web sockets? i'm sending back a JWT which then gets sent back with every web socket push. does that make sense or is it totally bananas?
that’s what I do
and my middleware on the other end of hte websocket checks for the jwt (if it asks for anything that requires auth, which is just about everything)
I keep the payload small by just sending ids for lookup in the jwt (where info is concerned) and caching the full data to value store on server side
but mostly the jwt is there for saying “this is really the person with user id 161”
so when your client connects, say for the first time, it sends an auto generated uid. your server then sets the uid on the session and sente is all peachy. but if you want to push a message to <mailto:[email protected]|[email protected]>, how do you reconcile that with your client side auto generated id?
every message is paired with the requesting client’s current UID
so for things that act like request / response I just keep it in those terms
for sending to all (or any) websockets belonging to user X my first instinct would be to keep a mapping from user id to socket UIDs (and then from there send to the ones that are still open for that user)
since users can have multiple tabs open to my app, I can’t 1->1 map user to tab, which means no 1->1 user to websocket is possible
now that I think of it, I should totally make that hash map and propagate it via my auth middleware
currently I don’t have code that does unsolicited server push to clients - each message starts with the client and gets 0 or more server responses (and all those responses just get uid of user’s websocket from the incoming message)
but yeah, with a simple hash-map update I could be doing push to clients too, if I ever need it
@pradyumna om/IQuery
and passing props to your component are very different
or, rather, when your component implements IQuery
, it does so because you expect om next to be passing props to it
IQuery
is mostly plumbing so that om next can know what data your component depends on and schedule re-renders accordingly
@noisesmith do you happen to have any open source code online somewhere regarding your sente implementation?
Not the relevant part, sorry