This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-17
Channels
- # arachne (1)
- # beginners (42)
- # boot (4)
- # cider (28)
- # clara (9)
- # cljs-dev (149)
- # cljsrn (5)
- # clojure (185)
- # clojure-austin (2)
- # clojure-dusseldorf (4)
- # clojure-italy (14)
- # clojure-norway (1)
- # clojure-russia (18)
- # clojure-spec (35)
- # clojure-uk (36)
- # clojurescript (78)
- # core-async (6)
- # data-science (20)
- # datomic (48)
- # emacs (1)
- # fulcro (2)
- # garden (4)
- # hoplon (47)
- # jobs (5)
- # jobs-rus (1)
- # leiningen (2)
- # lumo (12)
- # off-topic (8)
- # om (8)
- # onyx (39)
- # parinfer (19)
- # re-frame (100)
- # reagent (15)
- # ring-swagger (1)
- # sql (8)
- # vim (1)
- # yada (20)
I'm going through the re-frame TodoMVC example application https://github.com/Day8/re-frame/tree/develop/examples/todomvc
but cannot get it work.
It seems that app be properly initialized.
initialise-db
event is dispatched at the very beginning: https://github.com/jumarko/re-frame/blob/master/examples/todomvc/src/todomvc/core.cljs#L49
However, after trying it run manually, I've found following error in JS console:
core.cljs:3679 No cofx handler registered for " :local-store-todos "
cofx handler is registered in db.cljs
, though: https://github.com/jumarko/re-frame/blob/master/examples/todomvc/src/todomvc/db.cljs#L78
If I try to register it manually, I got following error in cljs-repl (no error in browser console):
#object[TypeError TypeError: Cannot read property 'call' of undefined]
Any ides what might be wrong?@jumar I'll see if i can reproduce
You've got the latest from rhe repo, right?
I also added following dependencies to :dev profile
:dependencies
[[figwheel-sidecar "0.5.13"]
[com.cemerick/piggieback "0.2.1"]
]
You used lein do clean, figwheel
to build ?
as per README
no, I use cider and
(use 'figwheel-sidecar.repl-api)
(start-figwheel!)
(cljs-repl)
I'll also try lein figwheel
in a momentalways make sure to clean 😄 that often trips me up
Damn, I'm seeing a problem too. So odd, I was running this last night. Uggh
Give me a few minutes
In project.clj
can you change the dependency to:
[re-frame "0.10.1"]
please
And it also works with cider. My bad: I blidnly add most recent figwheel-sidecar version (0.5.13) but didn't noticed that todomvc uses 0.5.6 (of lein-figwheel)
no problem
I'll get the examples over onto the latest dependences
They have fallen a bit behind
Btw. any tips how to debug this type of problem? Let's say there's a real problem in re-frame's code handling reg-cofx
. How can I get something more useful than just #object[TypeError TypeError: Cannot read property 'call' of undefined]
?
I normally try to be careful to give reasonable error messages
Not sure what was going on there
I'll have a further look
Once I've got these dependencies sorted
Thanks. I think that error messages are usually great - e.g. "No cofx handler registered for " :local-store-todos " was really useful. Furthermore, thanks for the great project and fantastic documentation - it's a piece of art 🙂.
Thanks!
But I'm always interested to know what was hard to understand
For me, coeffects (https://github.com/Day8/re-frame/blob/v0.10.1/docs/Coeffects.md) were/are a bit harder to grasp. I mean, it all makes sense, I just had to re-read the docs 🙂.
Hmm. Intereesting
I was a bit confused by inject-cofx
- I expected that additional data will be automatically available in coeffects map without calling inject-cofx
in every handler. However, I think it all makes sense...
Okay, I've just pushed new deps for the two examples
We're up to date
@mikethompson I should take a closer look at behavior trees. The thing I like about FSM here is that so many of us already understand them. It feels like a very intuitive model of computation, and I really think it resonates with people. Developers seem to like it.
Using FSM made UI development a lot less painful for me. But it was really the blend of FSM & Clojure’s rich data literals. The combination lets you create this model for your UI that is concise but so expressive — I love it!
And I’ve seen other devs use that technique, have that “aha” moment, then watch it bleed into the rest of their UI work, happily.
I got a question about reframe subscriptions. I am trying to work from the lein re-frame template. but when I wanted to modify the default db to contain something else then the :name i can not seem to subscribe to the new element. Even stranger even though I remove the the :name from the default db i can still subscribe to it. I was thinking that it was cached but even after multiple restarts i still have the same issue. Any hints on how I can solve this?
@jebberjeb I am very interested in using FSM for UI dev for the same reasons you are: Trying to get some clarity into UI dev. re-frame has helped in a huge way, and I think an FSM will make it even better. I’m particularly interested in state charts since they provide hierarchical/parallel states and history.
@newres i suggest installing the re-frisk
debugger and checking your app-db
with that
@mikethompson thanks for the pointer to behavior trees. They look interesting and I’m testing them now to see if they could fill my needs.
@jhund I’d be curious to see what you think of using state charts if you get a chance to. I’m wondering about the tradeoff in complexity vs the power they bring.
I’m considering a partial implementation of statecharts as per SCXML to keep it as simple as possible.
I know that Alan Shaw did a talk on it: https://www.youtube.com/watch?v=klqorRUPluw
I think you can get some of what state charts has to offer without actually using them. I think STD’s can be composed at least, without a lot of added complexity. That’s what I’m currently working on.
STD being considerably simpler, my thinking is to try and get as much mileage out of them as possible.
@sandbags I added re-frisk and suddenly the db is now in the proper state without me doing anything else.... Well I guess that solves the problem. Thanks!
@newres Had you restarted the app totally before? If not, my guess is that the restart to add re-frisk fixed the problem.
@deg I thought I have restarted before, did a lein clean as well, but it seems I must have missed something. It seems to work properly now, even if I change the db state.
@erichmond What do you mean by "html escape"?
@erichmond isn't that just url encoding? you can do that with the JS built-in functions
TLDR: Can reg-sub-raw contain a let with multiple reaction bindings, and then return a reaction that deref these? Not quite sure I can phrase this in a good way, but here goes: I’m trying to use reg-sub-raw to avoid some expensive computation to be re-run on every change to app-db. Examples in re-frame doc “SubscriptionFlow.md” wraps the entire subscription function in a reaction, but they don’t use app-db itself inside the computation, only subscriptions. In my case I utilise app-db, so my thinking was to use let bindings to create several reactions, and have the final reaction utilise these and hence only need to re-run when any of them change. Nothing seems to run when I do this, so I’m trying to clarify whether I do something wrong, or if my thinking is wrong altogether. Do I e.g. have to do like the examples, and have every dependency for the calculation as a separate subscription, avoiding deref of app-db itself?
one other stupid question. What is the way that people have mapped env vars to specific environments?
@erichmond on my last project, we did it by making an http call to the server to get back the config object as json in an initialization step.
@mokr are you aware of the difference between "Level 2" and "Level 3" subscriptions?
https://github.com/Day8/re-frame/blob/master/docs/SubscriptionInfographic.md
"Level 2" subscriptions extract data directly from app-db
(which is "root" of the signal graph, and known as Level 1).
Whereas "Level 3" subscriptions only have other subscriptions as input. They do not extract directly from app-db
. So Level 3 subscriptions represent "intermediate" nodes in the signal graph.
Level 3 nodes will only "rerun" (expensively?) if their "input subscriptions" change. Ie. the propagation of values through the signal graph is pruned back at Level 2 when it is found that there were no changes to the relevant parts of app-db
. The expensive "Level 3" work is not done unless it needs to be.
just found out that it's possible to put re-frame views in cljc files so that they can be used on Clojure as well 😮
Yes, see re-frame-test
does it mean that I could do quite a lot of work without even firing up clojurescript?
yes I saw that too
that's pretty awesome
But note: React and Reagent obviously require a javascript environment
yes sure at some point I have to look in the browser
but there is no harm in theory in moving everything to cljc though right?
So, you can be testing your event handlers and subscriptions on the JVM
No harm
things like #(dispatch [:email (-> % .-target .-value)])
which are more javascripty will also work?
well that's dispatched on change of an input field anyway so I guess it would not be triggered anyway without the browser interaction
Yeah, i assume that is in a View function. And view functions are Reagent/React .... which means javascript needed
so does it mean I should use this as well to do some server side rendering of the html files?
I thought I needed something extra to do that but maybe not
@andrea.crotti there is a section at the very end on this ... https://github.com/Day8/re-frame/blob/master/docs/External-Resources.md#server-side-rendering
See "Server Side Rendering"
hi, I want to have events that affect only one instance of a component, in Om land this was done with core.async
a better way in re-frame?
if I dispatch an event for the component, it affects all instances
(like in (rf/dispatch [:my.app.the.component/show])
)