Fork me on GitHub
#fulcro
<
2018-06-11
>
tony.kay04:06:39

Fulcro 2.5.8 is up on Clojars. Fixes a bug in server-side rendering reported by @levitanong, and a websocket bug that where early sends to the server could cause errors while the websocket was establishing. Also fixes a bug where :component could be nil within mutation handlers if the component had no query.

šŸŽ‰ 32
šŸ‘ 16
myguidingstar10:06:48

hmm, I can't use qualified keywords for my route params because the fulcro syntax for routing tree use prefix: param/...

myguidingstar10:06:04

;; current fulcro syntax
(r/routing-tree
  (r/make-route :my-screen
    [(r/router-instruction :router [:my-screen :param/x])]))

;; my dream syntax so qualified keywords work
(r/routing-tree
  (r/make-route :my-screen
    [(r/router-instruction :router [:my-screen {:param :qualified/x}])]))

tony.kay14:06:38

yep. The built-in routing is tuned for use with URI-based parameters, which are not qualified. Feel free to write your own. The code for the existing (non-dynamic at least) routing stuff is very little code.

tony.kay15:06:34

The routing tree is a very simple thing I threw together to set idents on more than one router at onceā€¦but it is just that: a mechanism to combine setting multiple idents on routers into a single mutation. Thereā€™s nothing magic about it unless you want to integrate with code splitting.

eric.shao19:06:31

(defcard-fulcro repayment-state-card
                Root
                {}
                {:inspect-data true
                 :fulcro       {:started-callback
                                (fn [app] (df/load app :foo loan-comp/RepaymentItem {:target (df/append-to *[:REPAYMENT-LIST :singleton :repayments]*)}))}

                 })
I used initial-state to give this position a [], Why this position is still nil so that it canā€™t be appended. Which happen first, initialState or :started-callback?šŸ™‚

eric.shao19:06:54

Either initial-state or started-callback?

wilkerlucio19:06:39

@eric.shao initialState will happen first since it goes at app initialization process, right after that your started-callback will be triggered

eric.shao19:06:50

@wilkerlucio I want to load one {} or a [] to append to the initial-stateā€™s list. There are three situations 1: when I donā€™t provide fulcro-started-callback, the initial-stateā€™s list [] will show correctly. 2:when i df/load a {} it will fail 3:when i df/load a [{}] it will replace the initial-stateā€™s list (instead of appending to that list) and report

for append must target an app-state vector.
(vector? (get-in state data-path))

eric.shao19:06:21

If the initialState happen first, there should be a [] , and it should be appended instead of replace, right? where is the problem?

levitanong20:06:29

@tony.kay does fulcro support running the app ā€œserver-sideā€? Like, creating a fulcro client, running loads, fulcro networking etcā€¦

tony.kay20:06:50

@levitanong no, but if you follow the patterns in the book all of your mutations will have helpers that can be used to simulate just about any action on the server

tony.kay20:06:09

the HTML5 routing sections talk about this

tony.kay20:06:33

Not sure why youā€™d want to ā€œrun itā€ā€¦how would you interact with it? Once itā€™s on the initial screen events are needed to ā€œdrive itā€ to some state

tony.kay20:06:08

and since those ā€œeventsā€ are always mutations, simply having those in functional form on the server gives you exactly what you want without any ā€œmachineryā€ in the way

levitanong20:06:36

@tony.kay The use case is when, for example, I need a set of itineraries that tell the user how to get from one latlng to another latlng. If I want to SSR, then the html I serve should already have those itineraries out. I was thinking that if, when the server receives such a request, it instantiates an app (a client running on the server, in other words), to perform requests from another server (the server the client-client would talk to)

levitanong20:06:59

if I could do that, it would be easier to reason about

levitanong20:06:07

plus, lots of nice code reuse

tony.kay20:06:45

sounds like a nightmare to me šŸ˜œ

tony.kay20:06:09

think of all of that machinery that can break and make it ā€œnot workā€ā€¦debugging, setup, testing, devops

tony.kay20:06:26

you already have the functions on the server to return the data, right?

levitanong20:06:35

the problem is, i donā€™t.

levitanong20:06:48

the server is primarily a webserver. it doesnā€™t hold the routing, reverse geocoding, etcā€¦

levitanong20:06:01

(by routing i mean in the google-maps way)

tony.kay20:06:04

ok, so, do your users have to be logged in for this?

levitanong20:06:21

currently no. thatā€™s something thatā€™s definitely in the roadmap though.

tony.kay20:06:27

so donā€™t SSR

tony.kay20:06:32

not the logged-in pages

tony.kay20:06:57

youā€™re creating work that simply isnā€™t going to do you much good

levitanong20:06:01

the login stuff is primarily for preferences, so itā€™s safe to be rendering the stuff

tony.kay20:06:03

and is going to cause a lot of pain

levitanong20:06:16

the motivation for SSR right now is SEO

tony.kay20:06:29

right, and SEO someoneā€™s specific iternerary???

tony.kay20:06:32

thatā€™s silly šŸ™‚

levitanong20:06:59

the itinerary thing is a simplification šŸ˜›

tony.kay20:06:18

Your best bet is really to use CLJC for the client mutations, and do the manipulation of data and only data on the server, then render that with SSR

tony.kay20:06:50

ā€œloadsā€ will have to be implemented to do JVM-based networking if you need to hit other servers to satisfy external data needs

tony.kay20:06:20

but the merge functions in Fulcro will work on the server against state maps, so you can get very close to complete sharing of code

tony.kay20:06:51

it is the advantage of pure rendering to begin with

tony.kay20:06:16

(and the single language on full stack)

tony.kay20:06:22

youā€™re already getting a lot šŸ™‚

levitanong20:06:58

i do suppose the statefulness of the instantiated app would be overly complex

tony.kay20:06:37

and maintaining two ways of dealing with networkingā€¦along with the alternate paths wthin Fulcro itselfā€¦itā€™d be a constant source of inconsistencies andbugs

levitanong20:06:21

the thing that actually pushed me over into asking about instantiating an app though, is in the case of invented-root-level-keyword loads.

tony.kay20:06:23

and at the end of all of that probably wouldnā€™t save you hardly any coding, since you could have already used CLJC shared code to ā€œrun arbitraryā€ operations server-side

levitanong20:06:52

because client-side, i have something like :placename->location and :location->placename. Both touch ā€œplacesā€, but fill up complementary deficiencies in information

levitanong20:06:37

as opposed to using an ident

levitanong20:06:13

and i wasnā€™t sure how to marry those invented keywords with the merge function

levitanong20:06:13

or maybe i know how to make it work, but itā€™s just one kind of mess that I wanted to cover up with a different kind of mess. šŸ˜œ

tony.kay20:06:44

you know about merge-component?

tony.kay20:06:56

all of the auto-normalization is available on the server

tony.kay20:06:10

and integrate-identā€¦both in primitives.

levitanong20:06:22

oh, those seem new!

tony.kay20:06:22

work on a normalized state map

tony.kay20:06:29

nopeā€¦been there for a long time šŸ™‚

tony.kay20:06:26

the ! form of them are mutations, and the non-`!` form can be used on server or inside of mutations

levitanong20:06:45

got it! thanks @tony.kay šŸ˜„

tony.kay20:06:56

coolā€¦yeah. Instead of a load, you just merge