This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-09
Channels
- # aleph (16)
- # bangalore-clj (1)
- # beginners (57)
- # cider (4)
- # clara (1)
- # cljs-dev (25)
- # cljsrn (12)
- # clojure (76)
- # clojure-dusseldorf (2)
- # clojure-italy (41)
- # clojure-russia (4)
- # clojure-spec (3)
- # clojure-uk (122)
- # clojurescript (101)
- # cursive (8)
- # data-science (30)
- # datomic (2)
- # emacs (2)
- # figwheel (10)
- # fulcro (53)
- # garden (5)
- # gorilla (6)
- # hoplon (1)
- # jobs (1)
- # juxt (14)
- # leiningen (12)
- # om (1)
- # om-next (1)
- # onyx (21)
- # pedestal (40)
- # perun (5)
- # portkey (2)
- # re-frame (16)
- # reagent (1)
- # ring-swagger (3)
- # rum (6)
- # shadow-cljs (239)
- # spacemacs (10)
- # specter (9)
- # uncomplicate (2)
- # unrepl (1)
- # vim (13)
- # yada (16)
@genec that sounding more like the old IBM/BPEL for this kind of bidirectional feedback loop, which gets messy once the processes get too complex. You may want to check out http://www.onyxplatform.org/ with commercial backing of http://pyroclast.io/, otherwise https://nervous.io/
Precisely so - I replaced an Oracle BPEL workflow engine with AWS Simple Workflow, which is the predecessor to Step Functions - though Pyroclast looks very interesting also. I was aware of it but hadn’t taken the time to look into it, so thanks for posting that link!
Hey guys. I'm trying to build a fitness tracker site using Chestnut (+http-kit +garden +reagent). It's an SPA with a front end and backend. I've integrated Secretary and Accountant for client-routing and modified the app div in my one HTML page using Reagent components. My question is should I create separate folders and/or files for routing and loading content into my div?
@jmb you may use re-frame-template as reference for the secretary setup lein new re-frame myapp +handler +routes
there is experimental https://github.com/chpill/re-frankenstein/, otherwise stick with re-frame+reagent as the best match 🙂
@alice i use hoplon/javelin, it's not react based though
@alice have you looked at hoplon?
I use my homegrown Tuck https://github.com/tatut/tuck
which just keeps state in one atom and the UI code gets a handle to send events (records)
Slightly OT: I have super fast reloads of JS files with figwheel in Chrome, it basically downloads all files in parallel. Though, in Firefox it's very slow. It just downloads them consecutively. Any tips? Server is Openresty w/ HTTP/2.
@rauh, is there a reason why you are using another server on top of figwheel?
@pesterhazy Not really, Openresty actually doesn't pipe them thru to Figwheel web server but serves them from disk. I haven't checked in a while: Does Figwheel server run HTTP/2 nowadays? By switching to Openresty last year my full page refresh got to 2sec from like 6+ seconds with figwheel.
ah that I don't know
firefox and chrome are different when it comes to caching resources - chrome defaults to aggressively caching every js file that doesn't have caching headers set
@pesterhazy I don't think it's a caching problem. The files (possibly 20-30) are loaded consecutively, instead of all together. Do reloads for you guys in FF happen in parallel?
why would requests be made serially? That doesn't make sense... unless you already have a ton of connections to the server open maybe?
@pesterhazy I'm wondering the opposite, how does chrome do them in parallel? They're initiated by js.
It must keep do something clever like figuring out that the next line of code doesn't depend on the js being loaded (how is that even possible?) and then continue execution until they find a point it becomes ambigous.
hi, i am using doo for testing clojurescript with node. when i set watch-mode to auto, the tests run twice. not able to figure out why. any advice?
@pesterhazy Yeah I'm looking at the figwheel code ( https://github.com/bhauman/lein-figwheel/blob/0ab52dca9289549eea31f11ef633d7f41c6033a2/support/src/figwheel/client/file_reloading.cljs#L313 ) at it seems to be serial
so maybe it is about caching?
I have an ugly hack that works with the latest figwheel version, which allows for a custom loader. It's very fast now. It's not super clean since it'll call figwheel :on-js-load
too early. But I don't care about that
(defn figwheel-load-js-file
[url cb]
(let [fulfil #()
reject #()]
(js/document.head.appendChild
(doto (.createElement js/document "script")
(set! -type "text/javascript")
(set! -charset "UTF-8")
(set! -src url)
(set! -onload fulfil)
(set! -onreadystatechange fulfil)
(set! -onerror reject))))
;; HACK:
(cb true))
(gobj/set goog.global "FIGWHEEL_IMPORT_SCRIPT" figwheel-load-js-file)
@pesterhazy It's def not about caching since my Openresty server will actually return a 304 for all unchanged files and a 200 for all changed ones. Probably another reason I get super fast reloads in general.
you could try reproducing the problem with figwheel-template to see if it's specific to your setup
Chrome is aggressively caching the js files (even though http hasn't told it to) and firefox isn't.
@dominicm, that's what I referred to above 🙂
I don't think it's caching, if it were it'd load faster. I also don't have issues with stale files, just reloading performance.
I don't recall it being particularly slow. But I'm not an active figwheel user anymore.
is it possible to call an event from another event?
(re-frame/reg-event-db
:end-game
(fn [db]
(assoc db :has-ended? true)))
(re-frame/reg-event-db
:select-color
(fn [db [_ color]]
(when (= (:real db) color)
;=> somehow call :end-game
)))
Check out reg-event-fx. https://github.com/Day8/re-frame/blob/master/docs/Effects.md
I quess you could for something like:
(re-frame/reg-event-fx
:select-color
(fn [{:keys [db] :as cofx} [_ color]]
(when (= (:real db) color)
{:dispatch [:end-game]}
)))
Pseudocode, did not try that one out 🙂
oh, so I can change the state values too. I thought it needed to be an interceptor without touching the state
:thumbsup:
(re-frame/reg-event-fx
:select-color
(fn [{:keys [db] :as cofx} [_ color]]
(when (= (:real db) color)
{:dispatch [:end-game]} <----- this dispatch right here
)))
What do you mean by timeout?
basically I’m trying to re-create this little game here: https://broken-hose.surge.sh/ but using clojurescript this time. There, I have a timeout that ends the game. And the user has to be fast enough to click the correct answer. Clicking the correct answer resets the timeout
@bravilogy Wrap it in a go
block and use timeout
so basically it shouldn’t get fired if the user clicks the correct answer, but rather it should start over
@bravilogy Most likely a better idea, disregard my previous input
I think the more “re-framish” architecture would be to trigger sort of :tick event every 500 ms or so, which checks from the app-db if the time has run out and then updates the app db accordingly.
I like that thinking @juhofriman but I can’t wrap my head around, how would I actually do it 😄
I would personally try to add something like :time-left 1000 to app-db, and decrement it on each :tick fx. When it comes to zero or less, I would dispatch :end-game. So time ticking and user input are two completely separate things which just happen to operate on same data 🙂
I have never done such an app with re-frame though 😛
Hmm, I would propably try to wrap timeout or interval inside reg-fx
, which is sorta effect handler for ungly side effects. Check out this one https://github.com/Day8/re-frame/blob/master/docs/FAQs/PollADatabaseEvery60.md
I’m having an unusual problem with lein cljsbuild auto
that I’ve not had before. It will automatically compile upon save and show that is Successfully compiled in around 1.X seconds. But this message doesn’t actually appear for about 10 seconds. Anyone else seen this recently with recent versions of the compiler?
I followed this example:
https://github.com/Day8/re-frame/blob/master/docs/FAQs/PollADatabaseEvery60.md
and how can I dispatch this :interval
from let’s say this bit:
(re-frame/reg-event-db
:start-playing
(fn [db _]
(assoc db :is-playing? true
:fake (random-active-color db)
:real (random-active-color db))))
so basically I’d like to initiate the interval right when the game starts, in this case when :start-playing
is finished updating db
hey folks, I have a huge static configuration file in edn format, is there any way to use the file in compile time and use the data with goog-define
?
if anyone feels like shedding some light https://stackoverflow.com/questions/46650792/how-to-dispatch-an-event-from-an-event-in-re-frame
There's also a #re-frame channel you could post this in.
@lxsameer If you are using Leiningen, unquoted forms inside defproject
in your project.clj
will be evaluated.. Leveraging that capability, you could read the EDN, extract the config of interest, and inject it into :closure-defines
as desired.
@bravilogy You don't use dispatch
for fx.
@bravilogy Instead, you'll use reg-event-fx
for :start-playing
and you'll return a map of the effects. In this case, {:interval [{...}]}
@bravilogy Something more like this: https://gist.github.com/jeaye/5f1da6d07f011120c4a95b3843aa3177
@bravilogy reg-fx
doesn't return anything of consequence. reg-event-fx
returns the effects to apply (with built-in ones like :db
and :dispatch
).
re-frame takes a good amount of reading to grasp all of this; I'd recommend going through the official docs a few more times.
The value that doesn’t support name is nil