This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-10
Channels
- # adventofcode (54)
- # announcements (30)
- # asami (13)
- # aws (10)
- # babashka (16)
- # babashka-sci-dev (44)
- # beginners (95)
- # calva (63)
- # clara (10)
- # clj-kondo (3)
- # cljfx (6)
- # cljs-dev (7)
- # cljsrn (1)
- # clojure (68)
- # clojure-europe (59)
- # clojure-nl (7)
- # clojure-norway (12)
- # clojure-spec (6)
- # clojure-uk (6)
- # clojurescript (4)
- # component (4)
- # conjure (5)
- # datomic (3)
- # deps-new (1)
- # events (4)
- # exercism (1)
- # figwheel-main (1)
- # fulcro (33)
- # gratitude (1)
- # improve-getting-started (3)
- # jobs (3)
- # lsp (5)
- # malli (10)
- # membrane (5)
- # music (3)
- # nextjournal (6)
- # off-topic (42)
- # pedestal (2)
- # polylith (14)
- # portal (11)
- # re-frame (42)
- # releases (3)
- # reveal (4)
- # shadow-cljs (62)
- # tools-build (1)
- # tools-deps (3)
- # web-security (1)
- # xtdb (3)
Hi - I'm seeing something that I don't fully understand and wondered if anyone can provide some clarity The context of this is that I'm playing around in a freshly cloned copy of fulcro-template. I'm calling transact! to communicate with a REST api and I'm getting a JSON response from the server I added a very simple response middleware to console log some details and can see the JSON string in the :body of the response My intention is to manipulate this JSON in the ok-action of the defmutation However, when I look at the :result key in the env in ok-action I can see the all the details of the response but the :body key is an empty map I tried removing my response middleware and even tried added some logging in the result-action of the defmutation and saw the same so.. would you expect the server response body to be empty in ok-action? maybe I'm looking for the server JSON in the wrong place? ..(I removed my result-action to restore the default behaviour).. as a temp workaround I find that if I duplicate the server JSON into a different key in the response middleware it is present in the ok-action but maybe I shouldn't need to do this.... .. thoughts welcome, happy to provide further clarification
I think you need a custom remote to use a REST api. Do you do that? There is surely an examine in the book...
I've done a bit more digging My question relates to what is happening between response middleware and ok-action Because Fulcro, by default, is expecting to be talking to something like Pathom remotely, it's trying to merge the response, the JSON doesn't "match" and so the body of the response becomes an empty map (^^^ this is a summary of my understanding, not a description of what the code is actually doing...) I've gone back to the book and tried a few options but I haven't changed the behaviour Any tips then on how I might tell Fulcro not to try merging the response so that the :body key remains intact?
Jakub provided the answer, remotes
handle communication in fulcro apps - the remote in the template does not handle JSON over https - here is a sample pathom parser setup to do that:
https://github.com/dvingo/my-clj-utils/blob/master/src/main/dv/fulcro_util.cljs#L578 - then you make http calls in your resolvers which return core.async channels
Thank you @U051V5LLP and @U0522TWDA for this and for sharing your repo - looks really useful I think I will need to come back to this - it does seem that using Pathom is the "correct" way It may not have been explicit but I had already created a new remote in my template code to handle the JSON (not sure about https yet..) and this is the context within which I was asking I'm doing some POC stuff around an existing backend and hoping that Fulcro (without GraphQL) will still be a good choice for a new frontend. I think I've got enough of this working for now to make progress and will climb the Pathom resolvers hill another day...
I think Fulcro filters out all that you do not query for => 1) make the json into Clojure data, 2) query for everything - add to you mutation st. like (remote [env] (m/returning env (rc/nc '[*])))
What does your remote look like? Do you use the mock-http-remote or the http-remote? Have you looked at https://github.com/fulcrologic/fulcro/blob/develop/src/main/com/fulcrologic/fulcro/networking/http_remote.cljs#L155 ?
really grateful for your continued support I'm using fulcro-http-remote and wrap-fulcro-response as part of the response middleware I tried adding your "returning everything" query and also tried completely removing wrap-fulcro-response from the response middleware .. same result something happening in fulcro-http-remote, in the ok-routine*, probably the ok-handler At the risk of parading my ignorance, is there a mechanism for either adding logging to the fulcro library code or better still getting a old fashioned debugger with breakpoints? ... I should stress that this isn't a blocker for me - I'm just trying to better understand and follow how this code and library are working
I have this in my deps.edn
:
:dev/fulcro {:override-deps {com.fulcrologic/fulcro {:local/root "/Users/me/fulcro-all/fulcro"}}}
(where I checked out Fulcro to /Users/me/fulcro-all/fulcro
) and if I run my repl with this alias then I can change Fulcro's code, e.g. to add println
or log/info
calls there or do any of the repl-driven-dev tricksYou can also https://ptaoussanis.github.io/timbre/taoensso.timbre.html#var-set-level.21`(set-level! :debug)` to see the logging statements fulcro has in place already
What’s the right way to introduce a new component layer at the root of your UI tree?
I’m doing todomvc, and I can’t figure out how to create a good query. My todos list is loaded at :todo-list
but because there’s a new component, I can’t get todo-list
from the root query, it needs to be in TodoList
but then there’s no root node for Root
to grab. What am I missing?
I can make the rendering work by passing the whole props map down to a layer in the UI tree, but it doesn’t that make my UI tree and query tree divergent? It feels wrong to me, but I don’t know enough to know if that’s bad for any reason
Can https://blog.jakubholy.net/2020/fulcro-divergent-ui-data/#_inserting_a_stateful_ui_component_between_a_parent_child_entities os some other part help?
Hi. I’m just getting started learning Fulcro. After I refresh my app web page, the DB in Fulcro Inspect is always empty. I have to close Chrome Dev Tools and re-open it, and then I can see my data in the DB. Is this normal?
It turns out that if I update the database after a browser refresh, Fulcro Inspect updates and shows the DB contents.
the message sent to inspect happens when the app is mounted the first time, but not on code reload: https://github.com/fulcrologic/fulcro/blob/develop/src/main/com/fulcrologic/fulcro/application.cljc#L327
Hmmm. A refresh definitely causes an empty DB to be shown. Here’s a video: https://drive.google.com/file/d/11_JbWqwgkKm-EATQ1WGQNKZh1aWq9ug6/view?usp=sharing
if you right click on the inspector itself and Inspect that there may be an error there
Here are the details: main.js:37898 DevTools tooltip root node not found; context menus will be disabled. (anonymous) @ main.js:37898 Qj @ main.js:17369 Gk @ main.js:18941 Dk @ main.js:18393 kg @ main.js:14190 Wk @ main.js:18802 Ok @ main.js:18743 Fk @ main.js:18320 J @ main.js:20007 R @ main.js:20044 main.js:4076 ERROR [fulcro.inspect.chrome.devtool.main:176] - Something was nil (anonymous) @ main.js:4076 (anonymous) @ main.js:4088 h.hc @ main.js:1837 Gd @ main.js:1526 ug @ main.js:1631 j5 @ main.js:4086 (anonymous) @ main.js:5543 (anonymous) @ main.js:1490 setTimeout (async) (anonymous) @ main.js:1490 Twb @ main.js:5538 axb @ main.js:5551 (anonymous) @ main.js:5556 n @ main.js:5554 yU @ main.js:2896 (anonymous) @ main.js:2896 (anonymous) @ main.js:2881 r8a @ main.js:2877 b.port1.onmessage @ main.js:2876
This is with code created by following section 4.4 of the Fulcro Developers’ Guide (at https://book.fulcrologic.com/#_create_your_project)
Reproduction at https://github.com/simon-katz/fulcro-app-from-ch4-of-the-book/tree/fulcro-inspect-gives-an-error
Do you have the problem with https://github.com/holyjak/minimalist-fulcro-template-backendless? I don't => explore differences. If you do, try different browser
@U0522TWDA Thank you. No problem with that repo. The difference is calls to app/set-root
and dr/initialize
in the client/init
function.
Commit at https://github.com/simon-katz/fulcro-app-from-ch4-of-the-book/commit/f4db23b7011f20eedeb125895a5a5cb745e8ab52 for anyone interested.
More complete fix at https://github.com/simon-katz/fulcro-app-from-ch4-of-the-book/commit/78e6c2ff56c7bcbb8f26870827882868c89df2bf
This change should not matter. You don't need dr of you don't use it and mount does the same thing as set-root+ mount, just in 1 step
@U0522TWDA It definitely makes a difference for me. 🙂
If anyone wants to try it:
1. Clone https://github.com/simon-katz/fulcro-app-from-ch4-of-the-book
2. Checkout the branch fix-fulcro-inspect-error
(not necessary right now, because that’s the same as the main
branch.
3. Compare the behaviour with and without the most recent commit.
I get the same behaviour with both Chrome and Vivaldi.
An update:
I had the same problem with the early parts of the Fulcro 3 video series, but when I moved from Part 5 to Part 6 (using a server and removing :dev-http
from shadow-cljs.edn
), the problem went away.
do fulcro apps work with :advanced
optimization enabled?
Yes. Of course. 🙂