Fork me on GitHub
#fulcro
<
2019-08-28
>
timovanderkamp09:08:42

Hi, where can I find the porting tool to migrate from fulcro 2 to 3?

timovanderkamp11:08:19

I’m pretty sure i’ve seen some messages about a tool.

timovanderkamp11:08:29

This is what I found in a slack archive:

timovanderkamp11:08:06

The repo doesn’t exist anymore though

tony.kay15:08:18

Hi @U4X0SB0HX, on the porting tool: frankly, I ran out of steam and just started porting things by hand. I didn’t want “support” requests, so I took down the repo.

tony.kay15:08:10

I have too many demands on my time, I spent about 20+ hours on the tool, and it still wasn’t working well…and I didn’t want many more hours of “the porting tool did X” messages here 😜

timovanderkamp17:08:53

Completely understandable!

tony.kay18:08:35

If you’re interested in finishing it, and publishing it under your own account (so you can deal with issues), I’m glad to provide the source

timovanderkamp09:08:58

I already started doing it by hand, so I’m fine thanks!

hoynk13:08:45

How hard would it be to use react-native with Fulcro?

souenzzo13:08:25

ReactNative isnt supported by fulcro But it works Here a working demo with ~200 LOC https://github.com/souenzzo/graph-demo/tree/91eb9ccb1a61697a57ff42e5e5d16f3bcfa4741f

hoynk14:08:59

Nice! Thanks 🙂

souenzzo14:08:53

feel free to send me questions 🙂

hoynk19:08:01

Thanks, will do!

maxt13:08:14

@tony.kay I also ran into defered-route not working, which turned out to be because i didn't do a get-initial-state of my TopRouter. The example in 14.7 doesn't, which I found missleading:

:initial-state {:root/router {}}

souenzzo15:08:44

do fulcro support something like (for [i (range 10)] ^{:key idx} (my-component-without-args)) (fulcro2 ATM)

tony.kay15:08:00

@souenzzo just pass :key as a parameter

tony.kay15:08:16

(my-component {:key idx})

tony.kay15:08:47

@maxt Yes, I reviewed the dr code…it is doing the “right thing” for initial state, assuming you also do the right thing 🙂

🙂 4
mss15:08:19

with the new ident-based optimized render in f3, does every component need to have an ident? getting a warning that my root component queries for state that changes, but does not have an ident. getting that warning both with and without an ident on my root component. all my root is doing is pulling in state from children via joins

mss15:08:34

nvm on the above, had a typo. loving f3 btw!

mss16:08:58

do have a follow up question, tho: in my client-did-mount hook, I have a post-mutation on a load call that routes the user to the correct screen. it doesn’t seem to be working with the dynamic router – it’s telling me that the route I’m trying to switch to isn’t installed. I assume that’s because the app hasn’t rendered yet or something is wonky with the instantiation order vs fulcro 2. how are people handling initial routing combined with loading/mounting?

tony.kay16:08:58

@mss Did you compose initial state of the router up to root?

mss16:08:23

nope, followed the example in the book so I assumed I didn’t need to

mss16:08:08

still getting the same error when I do, tho

tony.kay16:08:10

You should generally run a change-route on client-did-mount as a first operation. There is an initialize! function in dr that you can try as well (it starts all of the router state machines), but I meant for an initial change-route to do the necessary work. I admit I’m a little unclear what I was thinking with initialize!.

tony.kay16:08:30

but then…beta 😄

tony.kay16:08:55

If the book doesn’t show initial state being composed, then that is an error

mss16:08:10

would any weirdness happen in your opinion if that change-route call happens inside of a load post mutation?

mss16:08:28

or is it the change route call that actually instantiates the router?

tony.kay16:08:38

so in F3 all transactions go into a queue…the intention being that such things that were a problem in f2 won’t be in f3

tony.kay16:08:54

post-mutation is just a normal transact! now

tony.kay16:08:00

going into the same (sequential) queue

tony.kay16:08:14

The first change-route starts the router’s state machine

tony.kay16:08:34

each router has a state machine…for tracking timeouts, deferred routing, etc.

tony.kay16:08:06

It you call initialize!, that starts them all at once…and it might be necessary to do that for your case, which might explain why I wrote it 😜

mss16:08:12

that absolutely makes sense

tony.kay16:08:29

So, if you look in Fulcro Inspect: there is a table that has the name ::uism/asm-id. each router will appear in there.

tony.kay16:08:48

There is also a ::dr/router-id (or something) that has the state of each router

tony.kay16:08:04

The ID of the router will be a keywordized version of it’s FQ name

tony.kay16:08:27

If you don’t see the router in the router table, then you didn’t get it’s state in initial state

tony.kay16:08:35

If it isn’t in the UISM table, then it didn’t get started (state machine)

tony.kay16:08:50

Fix those two, and it should work

mss16:08:13

fantastic, thanks for the help. just filed a change for the dynamic router book example to compose the initial state correctly into root

tony.kay16:08:03

great, thanks

tony.kay16:08:13

Beta 10 is on clojars. Fixes an issue where hot code reload causes a re-mount of DOM nodes at the react level (which re-runs componentDidMount, etc.)

tony.kay16:08:27

Also adds ::uism/app to UISM env

tony.kay17:08:23

@mss this is a common misunderstanding. The book was actually right. See http://book.fulcrologic.com/fulcro3/#_initial_state I’m guessing you were using a lambda form in your code, which is not “magical”…the non-lambda form is a bit magical.

👍 4
tony.kay17:08:26

In hindsight, making the initial state key “magical” might not have been the best move for user clarity…it gets lost in the documentation

Björn Ebbinghaus17:08:20

Is there a convention when to add a bang (!) to a mutation? Noticed it in the template (`signup!`)

tony.kay18:08:17

I just found a bug in dynamic routing on deferred routes…fixing…

tony.kay18:08:51

@mroerni I’m trying my best to follow the Clojure convention. If it side-effect (isn’t ref. transparent) then it should have one…I make exceptions for logging, since they are technically side-effects, but don’t affect the referential transparency in a meaningful way

tony.kay18:08:04

beta-11-SNAPSHOT has a bug fix for deferred routing

wilkerlucio18:08:45

@tony.kay @mroerni I think from the mutation point of view its arguable, given that all mutations are expected to change the world in some way, wouldn't ! be redundant?

tony.kay18:08:26

@wilkerlucio actually that is a good point, and I rarely include ! on those…and the naming convention for mutation helpers is a suffix of *…though for the most part the helpers are pure

tony.kay18:08:28

I admit to being a little inconsistent at times…lots of things to keep track of in lib design and examples

wilkerlucio19:08:36

yeah, on my side I don't use ! on mutations

Björn Ebbinghaus19:08:49

First thought was that this was because signup! is mutating the state in the backend. So reloading the page would (maybe) yield a different state now. Toggling a dropdown on the other hand would not have an impact. Saying that: mutations should not have bang, following Clojure convention. The transact! does the state change while calling a mutation has no side effect per se.

👍 4
hoynk19:08:42

Hi, noob question, I am following the getting started on the Fulcro 3 book and can´t make the code reload when I alter the client.cljs file (it reloads if I change then shadow-cljs.edn file). I was just trying to alter the text on the div.

davewo20:08:03

You've started the main build with "start watch"?

hoynk20:08:05

Yes, by clicking on the button on http://localhost:9630/build/main

tony.kay21:08:40

@UBEQ9K406 which version? beta-8 (or 9) made some changes to hot code reload, there could be a regression. Try beta 6 or 7…does that work?

hoynk21:08:01

I actually tried beta-10

tony.kay21:08:17

nope…other way around

tony.kay21:08:25

this could be an UNFIXED regression 🙂

hoynk21:08:32

Something tells me its a shadow-cljs thing... will try 6/7

tony.kay21:08:33

might work in older

tony.kay21:08:42

I doubt it is shadow

hoynk21:08:01

Still not working with version 6.

tony.kay21:08:05

It could be a mistake in my instructions, or some missed config on your part…cannot diagnose without seeing the source of the project

hoynk21:08:20

One important thing to note is that I am using docker with a mapped folder (though I don't think that is the case because the reload triggers when I change the shadow-cljs.edn file).

tony.kay21:08:52

it is possible that is the problem…perhaps the file change detection isn’t working?

hoynk21:08:07

It is the first time I am using shadow-cljs, fulcro and tools.deps, so it is quite probable I did something wrong in the configurations.

tony.kay21:08:35

hot code reload relies on 2 things: - shadow detects change, compiles, pushes new code - Shadow invokes a function to re-mount the fulcro app

tony.kay21:08:15

you can look at Chrome dev console to see that code was pushed (regular network tab)

tony.kay21:08:50

where refresh is coded like this:

tony.kay21:08:09

the upsert-css is if you’re using garden css lib

tony.kay21:08:15

really just the mount is needed

tony.kay21:08:29

I’m actively working in workspaces on F3, and my hot reload is fine on latest

hoynk21:08:09

I will try by starting with the template.

hoynk14:08:10

I am 99% sure that it is a docker problem. In the end I solved by using a file watcher specific for docker. https://github.com/zippoxer/docker-windows-volume-watcher

👍 4
hoynk19:08:34

Any ideas what I am doing wrong (tried many shadow-cljs versions).

mss21:08:52

any suggestions on how to debug nil passed to get-query? trying to find where from root I might be missing something that’s composing in nil, but I can’t seem to find it at first glance

tony.kay21:08:33

@mss There is some chance that is a loading issue. The new code attempts to look up components in the registry. I think there might be cases where hot code reload order could cause problems…just guessing

tony.kay21:08:12

in terms of your question: how to debug. Look at the stack trace…you have source maps, so I would hope that the offending call to get-query would be in it

mss21:08:47

unfortunately the offending call isn’t in the stack trace beyond a mention of the dynamic-routing/initialize! call but since my views are composed top-down it could be almost anywhere in my app afaict

tony.kay22:08:53

routing initialize calls get-query

tony.kay22:08:18

so, the way dyn routers work @mss, is they scan the query for all of the routers, which means that your entire tree of get-query is going to be called. The thing is, you certainly don’t call (get-query nil) yourself, which means that some class you did list didn’t have its query configured (yet?). Check for mis-spellings of :query in your component options.

tony.kay22:08:38

As far as “debugging” it: you could clone fulcro and add it as a local/root dependency, and then add log/spy around various expressions called in initialize! to see where it is going wrong.

tony.kay22:08:25

technically, local source will be scanned first, so you could just copy over dynamic-routing ns, put it in the right package, and edit it locally that way

tony.kay22:08:24

I should also add some logging around get-query that might help it be more revealing…looking at that now

tony.kay22:08:45

some other possibilities: routers with no list of targets

tony.kay22:08:52

@mss try beta-11-SNAPSHOT

tony.kay22:08:48

I pushed another copy of that snapshot…extra warnings might help

mss23:08:10

great, let me dive into this a little bit later tonight and will get back to you. have a feeling between peeking around the extra logging now in the snapshot and cloning/running locally that I’ll be able to get to the bottom of it

mss23:08:20

will let you know what I find. really appreciate the help