This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-05
Channels
- # admin-announcements (1)
- # architecture (29)
- # beginners (244)
- # boot (5)
- # cider (2)
- # clara (8)
- # cljs-dev (58)
- # clojure (93)
- # clojure-australia (1)
- # clojure-dusseldorf (4)
- # clojure-france (1)
- # clojure-greece (16)
- # clojure-italy (9)
- # clojure-norway (1)
- # clojure-romania (1)
- # clojure-serbia (3)
- # clojure-spec (68)
- # clojure-uk (103)
- # clojurescript (41)
- # code-reviews (4)
- # community-development (4)
- # cursive (11)
- # data-science (2)
- # datascript (6)
- # defnpodcast (4)
- # docs (21)
- # duct (4)
- # emacs (118)
- # fulcro (120)
- # graphql (1)
- # jobs (1)
- # jobs-discuss (43)
- # leiningen (12)
- # off-topic (39)
- # onyx (11)
- # parinfer (13)
- # perun (1)
- # re-frame (2)
- # shadow-cljs (4)
- # spacemacs (5)
- # unrepl (6)
- # yada (1)
http://book.fulcrologic.com updated with a few more fixes and clarifications. the i18n demos work correctly now
how do I add custom headers to all http requests?
I'm trying to attach csrf tokens
It’s on the TODO list to add a hook to let you rewrite the requests before they’re sent
also, I'm trying to implemet (:column {:with "params"}) in fulcro-sql but don't know where to start
any suggestion?
something: filtering (where statements)
but the nothing case is interesting
If I understand it correctly, filtering is not part of om.next query
The idea is that you send some top-level params with the overall query, then transform them to the general filtering form and then run the query.
I see you’d like to embed these as parameters at the keyword level in the graph query itself (not at the top)?
Here are the cases I was thinking of:
1. You need to constrain all incoming graph queries. E.g. your schema uses a deleted flag, and you want that to be in the WHERE as deleted = false
2. You have some specific use-case on the client, but the graph query is already on the components. Use (load this :x Comp {:params filtering-params)
, and then have the server grab the top-level params and use those to convert to the filter general form
I may misunderstand the easy filters. Can you give an example inside a (load ...)?
The idea was that for some specific query it was likely you had some combination of filters that you were thinking about at some specific client call site
(defquery-root :people
(value [env {:keys [filters]}]
(let [query-filters (sql/filter-params->filters filters)
...
ah, I see
got it
let's get back to the "nothing" case mentioned
So, for that, fulcro-sql just needs a pre-processing step on the query to strip params
eg: (:column {:unit "cm"})
Unforunately I was trying to keep it from having a dep on Fulcro itself….the AST stuff there would make it very easy.
then it’s just a simple conversion to an AST, nil out all params recursively, and convert it back to a query
it would be a good exercise to see how hard it is to convert fulcro-sql to use pathom
it also isn’t that hard with clojure.walk…if you find a list, convert it to it’s first
incoming query -> ast -> collect pairs of [column with params, path to it] while return params stripped-> query non-param version against sql db -> result -> apply some transformations to collected paths
query -> clojure.walk convert list?
elements to (first ele)
(this is a query without params) -> run query -> result
I mean we not only remove params from queries but also save the paths to them for post-processing later
transformations based on params, say convert query result to specicied units (cm)
right, it's external
I’d be open to having you be able to use a namespaced keyword in parameters on a property as a way of giving filters, but that could be a rather extensive change…and I’m not sure it even makes sense
It may turn out that using something like pathom
makes a lot more sense in general (directly)…since it lets you define how your query is processed at every step
Remember that each join could be a to-one or to-many…your conversion example is doable, but other things won’t make sense without code to evaluate context
cool, I'm still trying to make sense of pathom
so, on fulcro-sql itself, you could do an experimental expansion and see how it goes.
Adding something that can gather the params that have the key :fulcro-sql/filter
and try to make use of that for filters might be interesting as well, but probably as a pre-processing step outside of run-query to start
I agree
For a general API, there are some hard cases…like where your graph query has the same subquery in two different branches with two different filters…the only way to deal with that would be to support the filter param during the processing of the query in run-query
your conversion example is also one that could be quite useful…say we have a multimethod in fulcro-sql where you can register namespaced keywords with conversion routines.
then your units example could be done in an extensible way that just involves data in the query
lots of possibilities…I guess a more general approach would be to have the parameters stay in the query, and run the results of the query through some kind of row filter that triggers on the table name, passes in the row and the parameters keyed by column name, and the row filter can return a modified row
I pushed 2.1.0-beta1 to clojars. The most significant thing here is that rendering has been refactoring and improved. There are now render modes. It is a beta because, well, it was an invasive change to rendering 🙂
The big wins:
- :ui/react-key
is no longer needed, ever.
- prim/force-root-render!
“just works”
- You can set the :render-mode
to :keyframe
(in reconciler-options) and no longer need follow-on reads. This isn’t as optimized, but will be fine (and simpler) for many apps.
The devguide has been revamped as a tutorial (much shorter), and content moved into the new book.
The website version of the (live) tutorial should work…but I’m still waiting for github to update the published version
@wilkerlucio https://github.com/fulcrologic/fulcro/issues/118 This repro example for the bug also includes repro for fulcro-inspect bug, transactions conducted by clicking the button don't show up in transactions tab of fulcro inspect
thanks, I'll take a look, can you please open an issue on inspect as well about it?
I posted a comment, was just a little issue with the transaction
much obliged
How did you make the book? I'm really impressed with it, both as documentation but also as an app.
@tony.kay your getting started dev guide, YouTube videos, and the rest are fantastically helpful. Thank you!
the videos are particularly helpful in getting started.
@astrashe It's asciidoc, ditaa (asciidoc-diagram), and some embedded HTML. Thanks, I think it's a big improvement over what I was doing before. The examples are all just one Fulcro build that outputs a bunch of mounts to divs on the HTML.
The macros for wrapping the examples are here: https://github.com/fulcrologic/fulcro/blob/develop/src/book/book/macros.cljc and the main for the "app" is here: https://github.com/fulcrologic/fulcro/blob/develop/src/book/book/main.cljc Embedding an example was then just literal blocks of asciidoc (and I admit to using JQuery to implement show/hide...since the book itself is just generated raw HTML):
++++
<div class="example" id="example-1"> </div>
<a class="source-toggle" href="javascript:void(0)" onClick="$('.example-1').toggle()">Show/Hide Source</a>
++++
[source,clojure,role="example-1 source"]
----
include::src/book/book/example_1.cljc[]
----
Couple of Live Templates in IntelliJ made typing these out as easy as typing the filename.
It's really impressive. I've been sending it to non-Clojure people, to show them how cool it is.
thanks...plenty of examples of docs on the web with live examples, though, aren't there?
about the next 100 lines there...isomorphic in both directions is nice...can embed a server on the client or client on server
The server
namespace includes a simple pre-written server-for-the-client like this, but it just runs happy path code...no error handling.
https://github.com/fulcrologic/fulcro/blob/develop/src/main/fulcro/server.cljs#L82
Oh wait...it looks like I did add in error handling to some extent there 😜
@macrobartfast Thanks....I probably need to redo some of the videos now...I just reorganized all of the docs and they probably refer to old stuff...if you could point out anything like that I'd appreciate it.
if I’m loading initial data from a server in my started-callback
that’s 1) going to exist at the root of the app db and 2) not cleanly associated with just one component, is it an anti-pattern to dispatch a bunch of loads that look like (df/load app :server-keyword-to-load nil {:post-mutation do-some-data-transformation})
?
as a follow up, how do you handle normalizing server-returned data assuming it comes from multiple different loads and there isn’t an associated component query to use to normalize the data?
am I just thinking about either of these questions wrong?
@tony.kay the new book is amazing! Would it be possible to make the TOC collapsible as a side menu? It would be much easier to navigate (e.g. jumping between topics/sections).
@mss A load without a component loads opaque scalar data. It should not be used to load a "database". The entire story relies on queries with idents to normalize. You can use defsc or defui to create component just for their queries for just this case. http://book.fulcrologic.com/#_using_code_defsc_code_for_server_queries
@piotrek Not opposed to the idea. If you want to look into asciidoc options and mess with it as a contribution I'm open. I've got other priorities
I think toc left would do the left part...collapsing it would just require a bit of jQuery probably...and perhaps a bit more CSS?
@tony.kay :toc: left
works great - I’ve just checked it locally - and it’s really enough, collapsing is not necessary at all. Shall I open a PR with this or would you handle it by yourself? The patch is trivial:
-:toc:
+:toc: left
I think that with this it is much better experience as you can start reading immediately without scrolling 10 pages (on my laptop) of TOC 🙂
@piotrek no PR needed. I’ll try it out. Anyone have comments on the number of TOC levels? It is set at 5, but that seems kind of deep to me perhaps.
I’m going to push an update with toc left and 2 levels. That is what I think is most useful. If you’re searching for something that needs the deeper levels you might as well hit CMD-F and just search for it.
Structure and Interpretation of Computer Programs has three levels ;-)
@tony.kay Practical Typography recommends two, max three levels: https://practicaltypography.com/headings.html
with 3 it’s probably nice if you’re seeing the book for the first time or you just want to review what’s in it, but it’s too much for quick nav
Since there seem to be at least 2 of you with opinions…why don’t I push one, let you look, then push the other? Got time for live feedback?
2-left is up on http://book.fulcrologic.com for the moment…
@piotrek @maridonkers care to opine?
Agree with two (SICP almost 700 pages)
Indeed it does look good on desktop and mobile.
I prefer version with 2 levels. 3 levels means a lot more scrolling and it’s actually easier to try to search on the page then scan the TOC