This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-18
Channels
- # aleph (1)
- # announcements (2)
- # aws (4)
- # beginners (73)
- # boot (2)
- # boot-dev (3)
- # cider (6)
- # cljs-dev (40)
- # clojure (64)
- # clojure-austin (2)
- # clojure-belgium (1)
- # clojure-dev (25)
- # clojure-estonia (1)
- # clojure-europe (16)
- # clojure-italy (11)
- # clojure-nl (4)
- # clojure-spec (90)
- # clojure-sweden (2)
- # clojure-uk (105)
- # clojurescript (58)
- # core-async (10)
- # cursive (23)
- # data-science (1)
- # datascript (3)
- # datomic (14)
- # duct (11)
- # fulcro (48)
- # graphql (1)
- # hyperfiddle (3)
- # kaocha (95)
- # liberator (1)
- # lumo (6)
- # nrepl (1)
- # off-topic (14)
- # onyx (2)
- # overtone (8)
- # portkey (3)
- # re-frame (31)
- # reagent (6)
- # shadow-cljs (185)
- # sql (12)
- # tools-deps (6)
- # vim (6)
- # yada (224)
General Notice: Fulcro Spec 3.0 is in out…it is a breaking change: I’m removing the browser renderers. I just don’t have the time to maintain them, they are flaky, and there are good alternatives. The shadow-cljs default test renderer is quite good at this point (I just ported Fulcro to it, and it’s fine), and Kaocha or an Emacs/IntelliJ/Vim in-editor runner for clj is better as well. The docs in fulcro-spec, and the example on develop of Fulcro show how to change up a project. Fulcro is getting a bump as well soon. I’m changing over to shadow-cljs for the development there because the experience is just so much better. I’ve pretty much got it going on the develop branch. Not sure what the version number will be yet. It should not look like much of a change externally…
also converting them to deps.edn, which could cause some dependency weirdness…that is the main noticeable change probably
Hi! I'm trying to follow along the fulcrologic book, but I can't get the remote data loading working. I'm at a point where my client is supposed load
in the :started-callback
, but I don't see anything in Fulcro Inspects Network tab, and when I try to call the callback manually using shadow-cljs's repl (with ((:started-callback @app.client/app))
), I get repl/invoke error Error: No protocol method IDeref.-deref defined for type null
. I've restarted the server, and refreshed the browser.
It seems like there's something wrong with my app initialization.. even when I do
(defonce app (atom (fc/new-fulcro-client
:initial-state {:some-data 42})))
, I'm not seeing any initial data in fulcro inspect, and repl says :initial-state of @app
is nilAh, I found the bug. The template the book uses has a new reset!
call in the init
function. I had to add the :started-callback
there instead
There’s an error in the book, or an inconsistency with the template? Either way I’d like to know about it 🙂
The template defs the atom as nil, and in the init fn resets the fulcro app into it
In the book you replace the nil value in the atom with a fulcro app
Ping @tony.kay, not sure you noticed this
When I said “detail”, I was looking for something that doesn’t require me to find the exact files and lines….something like “In the book where it says “something I can search for with a reasonable chance of accuracy” and in the template in file xxx it does blah on line xxx…The book is 500 pgs 🙂
Even better would be github links to lines. The develop guide is in the root of the fulro repo, and the lein template is OSS as well
Ah sorry, I'll try to remember to do that tomorrow 🙂 I understand completely
I was on mobile when I wrote that
http://book.fulcrologic.com/#_setting_up_a_server under header "Triggering the Load". The example says to change the (defonce app (atom ..))
. I think the example should be this
(ns app.client
(:require [fulcro.client :as fc]
[fulcro.client.data-fetch :as df] ; (1)
[app.ui.root :as root]
[fulcro.client.network :as net]))
...
(defn ^:export init []
(reset! app (fc/new-fulcro-client
;; This ensures your client can talk to a CSRF-protected server.
;; See middleware.clj to see how the token is embedded into the HTML
:networking {:remote (net/fulcro-http-remote
{:url "/api"
:request-middleware secured-request-middleware})}
:started-callback
(fn [app] ; (2)
(df/load app :current-user root/Person))))
(start))
I checked that this applies to the updated fulcro template too. @tony.kayAh, I found the bug. The template the book uses has a new reset!
call in the init
function. I had to add the :started-callback
there instead
@tony.kay Hi 🙂 Is https://github.com/fulcrologic/fulcro-template what I should be looking at for an up-to-date example of how to set up an application with routing?
I think the dynamic routing in incubator is going to eventually be the best…and the features are good…the problem is it isn’t battle tested yet. It is known not to work with SSR, for example.
@tony.kay Ah, well, I have no need for SSR. I just need routing that I can get up to speed with quickly. My use-case is a fairly simple application with a login page, and once logged in a few routes (some of which with route parameters).
Would the dynamic routing be more straightforward to implement / play better with Fulcro ?
Also, would it make it more straightforward to load data for specifc routes then render the UI, etc?
Additional question: is there a neat way to fit an authentication flow into this? Roughly speaking I would want to put most of the routes behind a requirement that the user is authenticated, and if no (after running a check against the server), redirect to the login route
You’re responsible for calling the route functions…so your logic dictates what is reachable…I’d use UI state machines in incubator
of course using a diff state machine on the login screen is nice too, and the docs show an example of one of those
Alright. I think I’ll look at https://github.com/fulcrologic/fulcro-incubator/blob/develop/src/workspaces/fulcro/incubator/routing_ws.cljs for guidance
There is some example of http://book.fulcrologic.com/#_a_warning_about_ident_and_link_queries + defsc-router
or defrouter?
NOTE: There is a new version of the lein template. It uses deps.edn, shadow’s test renderer, pathom for the back-end, and kaocha for clj tests at CLI.
Just tried it out tonight; it’s great. A lot of it I had to set up manually on my project (i.e. koacha); it’s nice to see it in a template. And it got me to watch a talk on Pathom
appreciate feedback, esp from @wilkerlucio on the pathom setup