This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-23
Channels
- # aws (4)
- # beginners (14)
- # boot (7)
- # cider (75)
- # clara (87)
- # cljsrn (6)
- # clojure (115)
- # clojure-berlin (2)
- # clojure-dusseldorf (2)
- # clojure-gamedev (8)
- # clojure-italy (15)
- # clojure-russia (9)
- # clojure-spec (46)
- # clojure-uk (195)
- # clojurescript (24)
- # css (44)
- # datascript (19)
- # datomic (18)
- # emacs (6)
- # fulcro (57)
- # hoplon (1)
- # jobs (3)
- # jobs-discuss (37)
- # jobs-rus (3)
- # luminus (6)
- # lumo (28)
- # off-topic (24)
- # onyx (11)
- # planck (8)
- # re-frame (31)
- # remote-jobs (12)
- # rum (10)
- # schema (4)
- # shadow-cljs (28)
- # specter (24)
- # sql (3)
- # tools-deps (34)
- # vim (43)
- # yada (10)
Having trouble using leiningen re-frame template. Getting an cljs.core.init is not a function
upon starting figwheel
@pablore did you call your project cljs? I.e. did you do lein new re-frame cljs
? If so, you should try naming your project something else, like lein new re-frame foobar
@pablore I'd try a name without dots .. that may cause some wonky behavior and isn't idiomatic. Given the error message, it looks like it lopped off name from name.cljs
I've added the following to the README
> *Troubleshooting note:* for <project-name>
don't use cljs
. That name will confuse the compiler and you will (later) see errors like cljs.core.init is not a function
I'm making a simple game using re-frame. When the game has finished I want to trigger an event (to save the score). Currently, I have a reg-sub
that returns whether the game is finished. Is it good style to create a dummy (non-visual) component ("view") that subscribes to this "game-over" value, and if it is true dispatches an event to save the score? Or is there some better way of doing this?
@jco I had a small pokemon game, where after enough good answers the game ends, and allows you to play again. You could have an event handler witch as co-effect saves the score?
@hkjels I determine that the game is over via a subscription that checks whether all blocks have reached their final positions (sokoban).
@troglotit OK, that could be nice, thanks.
@gklijs I'll probably do something like it. The question was mainly how to call this event handler, but I'll probably have to check if the game is over from my make-a-move
event handler (by directly accessing the app db), instead of relying on the game-over subscription.
(defn successful-try
[db]
(let [new-db (-> db
(update :score inc)
(update :total-tries inc)
(assoc :tries-left nil))]
(cond (= 10 (:score new-db)) (-> new-db
(assoc :re-start-enabled true)
(assoc :question {:finished true}))
(:next db) (assoc new-db :next-enabled true)
:else (assoc new-db :show-next-when-ready true))))
this was mine solution(re-frame/reg-event-db
:select
(fn [db [_ id]]
(if (:tries-left db)
(let [new-db (update-in db [:options id :selected] not)
selection (get-selected (:options new-db))
answer (get-in db [:question :answer])]
(if (= (count selection) (count answer))
(if (= selection answer)
(successful-try new-db)
(failed-try new-db))
new-db))
db)))
to be called when the correct answer was given.No, but the source is on github, https://github.com/gklijs/pokequiz it uses the open pokeapi.
It was quickly setup in a week during train and some evenings, nothing that fancy. But was quite fun last Christmas.
is there a visualization or charting library that integrates well with re-frame that is simpler than d3? I am reading sensor data from a firebase realtime database and want a live graph of readings over the past 24 hours.
I've heard great things about vega and vega-lite https://github.com/metosin/vega-tools and https://github.com/metasoarous/oz look like good places to start
thanks, I will look into it
If you want simpler then look at vega-lite
vega and vega-lite are layers over the top of D3
vega is very powerful, but also quite a bit to learn
vega-lite is much simpler and probably powerful enough
Just to be clear, oz
and vega-tools
(links above) let you embed vega (and vega-lite) into reagent.
Apart from that please look at https://github.com/Day8/re-frame/blob/master/docs/Using-Stateful-JS-Components.md
thanks. I have read the Using Stateful JS Components doc. Just with not being very familiar with react/reagent or d3 makes it seem like a pretty daunting task