Fork me on GitHub
#fulcro
<
2019-05-28
>
carkh07:05:31

ok i don't get it. i tried and tried but there is no way i could find to put the data of a component directly in the root of the database. I can fake it with a [:my-component :singleton] ident, but that's cheating. The examples i've been looking at in the book don't seem to translate, must be a version thing.

carkh07:05:28

i tried with the [my-component '_] query, but then the data stays in ui/root, unless i define an ident, in which case it goes in a my-component table at key _

carkh07:05:11

that's not very important but i feel there is something i didn't understand and that bugs me to no end

carkh09:05:36

i can read data from root, but it looks like fulcro won't help me create data at the root ?

carkh09:05:04

so i need to take matters in my own hand and do the writing myself ?

kszabo09:05:14

yes, reads and writes are separate

kszabo09:05:58

your queries deal with how to get the data, Fulcro helps via df/load to populate your DB

carkh09:05:42

right, but i was trying to use the initial-state entry to populate the data

carkh09:05:53

so you're saying i won't be able to populate in the root ?

kszabo09:05:14

at the root component the need for the [:kw '_] is unnecessary

kszabo09:05:22

since you are already at the root

carkh09:05:58

hum but if i don't do this, i see everything at :ui/root in my database

kszabo09:05:16

(ns app.ui.root
  (:require
    [fulcro.client.dom :as dom :refer [div]]
    [fulcro.client.primitives :as prim :refer [defsc]]
    [app.ui.components :as comp]))

(defsc Root [this {:keys [root/message]}]
  {:query         [:root/message]
   :initial-state {:root/message "Hello!"}}
  (div :.ui.segments
    (div :.ui.top.attached.segment
      (div :.content
        "Welcome to Fulcro!"))
    (div :.ui.attached.segment
      (div :.content
        (comp/ui-placeholder {:w 50 :h 50})
        (div message)
        (div "Some content here would be nice.")))))

kszabo09:05:37

for this particular example theres no app-db view

carkh09:05:16

let me plug this in my test project

👍 4
kszabo09:05:20

but I guarantee that (prim/get-initial-state Root) will have a {:root/message "Hello!"} in it

carkh09:05:59

well here is see this in the database -> ui/root ->root/message

carkh09:05:22

mhh maybe workspaces are messing with it ?

carkh09:05:10

maybe with devcards i'd see results closer to the book ?

carkh09:05:19

the get-initial-state call indeed gives the result you say, but that doesn't get me closer to having :root/message at the root of my database =(

carkh09:05:28

thanks though =)

hmaurer10:05:05

@carkh did the code that @thenonameguy gave not give the desired result?

hmaurer10:05:35

> well here is see this in the database -> ui/root ->root/message do you have an ident on the Root component?

hmaurer10:05:20

ah wait you are using workspaces.

hmaurer10:05:27

it shoves things under :ui/root

carkh10:05:09

@hmaurer right, my root component will end up in :ui/root ... but how about a sub-component ? is it possible to tell it to act from the root, not from a "table"

carkh10:05:25

in the example i gave earlier, (when i fix it up to be working) i can access the ui/locale from root

carkh10:05:02

what i would like is my component data to be located in such a place

carkh10:05:38

then again, that's not too bad, i can use an ident with a :singleton key

hmaurer10:05:30

I don’t get your problem with :ui/locale; can you elaborate ?

carkh10:05:31

i worry that i might understand it better when i'm waist deep in the project and then have to refactor the whole thing

carkh10:05:36

@hmaurer not a problem, i take this key as an example of what i want to achieve, and noted that i can query for it,

hmaurer10:05:15

so yes, you can use '_ to query “from the root”

carkh10:05:45

the question is ... is it ok to have this level of indirection (every singleton component in it's own table) or will i come to regret that

carkh10:05:12

This would be an example of something that works, but with an indirection to get to the counter data

hmaurer10:05:34

I can’t answer that question from experience, I would say it’s case-by-case. It’s absolutely fine to have singleton components if you want to associate them to data loaded in the DB

hmaurer10:05:06

yeah I would say that makes sense

carkh10:05:32

allright, thanks for your time =)

carkh10:05:41

i owe you a pint or three already

😄 4
kszabo10:05:43

@carkh we usually do :ident (fn [] [:COMPONENT/by-id :my-singleton-component-name])

kszabo10:05:14

just so that we have a dedicated table for singletons

carkh10:05:20

oh put all singletons in the same table

kszabo10:05:28

and this way there are less top level keys

kszabo10:05:35

easier to drill down into proper tables

carkh10:05:42

good idea

kszabo10:05:16

we went through the same refactoring that you try to avoid 😄

kszabo11:05:49

my rule of thumb is: let everything have a query+ident+initial-state, avoid root props unless you have a good reason to use them

carkh11:05:51

that's what i've been doing, not out of a decided upon rule, but rather because i couldn't find any other way to do it =)

daniel.spaniel13:05:08

Hi Tony, I hate to wake you up from your fulcro 3 stupor, but we have strange issue with routing. We have our routable routes, and our root rout that declares them, and then we had a list of 8 routes, but then a particular route ( lets call it A ) stopped working. when we comment out / remove a route ( pick one, any one besides A ) then route A works again .. truely bizzarro

hmaurer14:05:40

A total shot in the dark, but I have had “bizzarro” issues like this before with shadow-cljs build caching. Busting the cache and re-building the app fixed it for me.

hmaurer14:05:52

Again, it might not be this at all. But if there is any doubt, might be worth a try

daniel.spaniel14:05:05

i will give that a shot .. and i know what you mean

daniel.spaniel14:05:53

oh well .. that not work, but was good idea

pvillegas1215:05:47

@U0CKQ19AQ looks like an issue with lazyness. When adding the 9th route target it breaks the loading of data of other routes. If we remove any one route of those 9 it works again. So 8 to 9 route targets is the problem.

tony.kay15:05:22

using new dyn routers in incubator?

tony.kay15:05:12

if it is lazyness, then forcing the data structure should fix it..e.g. with vec

tony.kay15:05:30

not sure which thing you’re referring to

tony.kay15:05:41

if that does fix it, would appreciate a PR

daniel.spaniel16:05:30

can you explain what you mean by "forcing the data structure with vec" ? me curious

tony.kay16:05:58

you’d have to show me the code that you say is broken by laziness

tony.kay16:05:04

But what I mean in general is: (map identity [1 2 3]) results in a LazySeq…whereas (mapv …) results in a vector…using vec on a lazy seq gives you a vector, not a lazy seq

pvillegas1216:05:59

In our

{:router-targets [CompanyDashboard CompanyDetails
                    Login Signup Config
                    PurchaseDashboard
                    InvoiceDashboard PosDetails]}
Adding one route above 8 breaks the other ones. I am seeing in fulcro inspecto that there are :alt0 to :alt7 only (8) which is an issue?

tony.kay16:05:44

not sure why that would be

tony.kay16:05:08

literal vectors probably change implementations at some breakpoint internally

tony.kay16:05:15

but that should not normally cause a visible problem

tony.kay16:05:41

like maps: they are arrays internally when they have less than 10 k/v pairs (I think that’s the cutoff)

pvillegas1216:05:22

The routes that fail are of the form /company/uuid/entities. The failure is that the route that is loaded is /company/uuid instead of /company/uuid/entities. Adding a ninth route makes it so that the state machine resolves to the prefix and not the full route for some reason

pvillegas1216:05:16

The state machine is not transitioning correctly

tony.kay16:05:02

ah, well, that could just be a bug in how the nesting logic resolves routes

tony.kay16:05:26

what is the declared prefix for the 9th?

pvillegas1217:05:34

I’ve changed it to various incantations with no change

pvillegas1217:05:40

No prefix, like aaa

pvillegas1217:05:58

it’s weird it breaks when adding a 9th, even if it is a static route target with nothing in it

tony.kay17:05:01

it tries to match prefix segment to a route target

daniel.spaniel22:05:02

might be the right code that is failing .. i wonder if we could run fulcro incubator in development mode so we could debug this locally ourselves? or is this one something you can test easily .. or do you need more info on our route structure ?

tony.kay22:05:50

you using deps?

tony.kay22:05:03

If so, just clone the project, and add it as a :local/root dependency

tony.kay22:05:24

in IntelliJ that’ll just pull it in, and you can add spies and such to the logic and see what is going wrong

tony.kay22:05:28

highly advised

daniel.spaniel23:05:26

sure thing, thanks tony

hmaurer14:05:17

@dansudol are you using Incubator’s routing or F2's master routing?

daniel.spaniel14:05:11

@hmaurer we are using fulcro.incubator.dynamic-routing

hmaurer14:05:55

ah; can’t help on that one, sorry 😞

daniel.spaniel14:05:20

ok .. no problem .. thanks for asking though

exit215:05:58

I know this probably varies from setup to setup. But are there generally tips for making the hot reload faster for Fulcro apps? My styles are instant, but when changing a cljs file I’m waiting somewhere between 15-30 seconds for a refresh.

wilkerlucio15:05:57

jezz, that's a lot of time, do you have any warnings on your project? and are you using shadow or figwheel?

wilkerlucio15:05:04

for perspective, I daily work in a huge fulcro project, and our refresh times usually go from 2s in avg to 10s in the worst cases (when changing files that have a lot of dependants), using shadow

exit215:05:28

No warnings, I’m using figwheel - this project used to be an untangled project and I migrated to fulcro about 6 months ago

souenzzo15:05:26

Using shadow-cljs, react-native and web targets, using a real phone, my feedback loop takes about ~5 second from change on code and see on phone screen

exit215:05:04

Thats amazing, I need that kind of speed haha

👍 4
wilkerlucio15:05:17

if you can try shadow, I would love to hear how it compares in your current setup

exit217:05:11

@U066U8JQJ I assume that would be a large undertaking to switch from fighweel to shadow?

currentoor17:05:24

@njj shouldn’t that large

currentoor17:05:10

i migrated a largish project from boot-cljs to figwheel and it didn’t require much (if any) source code changes

currentoor17:05:20

just build config stuff

currentoor17:05:48

which can be a time sink if you’re not familiar with the build tool

currentoor17:05:08

but it’s not going to be anything like going from untangled to fulcro

currentoor17:05:36

FWIW shadow did feel faster for me when i switched to it, but i don’t have hard numbers

currentoor17:05:49

regardless there are somethings you can do that will help speed up compile times on both

currentoor17:05:20

avoid making huge utility/helper namespaces that are required all over the place

currentoor17:05:59

for example we have one util.clj file that is used everywhere, and touching that is the slowest re-compile

currentoor17:05:31

so we pulled various functions out of that into lib/datetime lib/math lib/counters etc

currentoor17:05:41

another trick that could work is pulling parts of your code out into separate libraries

currentoor17:05:28

the trick is basically to reduce the number of files your tool will have to re-compile (i.e. the file you touched and all the files that required it)

currentoor17:05:51

you’re styles are instant most likely because you have way less CSS files/code than cljs

currentoor17:05:30

well that and the fact that cljs compile is much more involved that SCSS or CSS 😅

wilkerlucio18:05:36

I guess the major different is how you handle the js libraries, most of then can just be converted to use strait from NPM, other than that it should be strait forward

currentoor19:05:14

@U066U8JQJ but even that is optional no?

currentoor19:05:39

shadow-cljs can handle whatever figwheel is doing, cljsjs probably

wilkerlucio20:05:40

nope, clsjsjs doesn't work with shadow at all

currentoor21:05:51

oh i didn’t realize, looks like it used to work

currentoor21:05:04

i haven’t used cljsjs in a while

hmaurer15:05:49

@njj sounds like we should add cloud compilation support 😬 Compile your CLJS on some massive server on AWS (assuming shadow can make use of many cores), and send the result back to you

currentoor17:05:13

sounds like it very much limit what you could get out of your build tool

currentoor17:05:38

for example i have a macro that uses fulcro.server/load-config in clojure while compiling a node script

exit215:05:25

This is figwheel

grzm23:05:49

How much hurt can I expect starting a new front end with Fulcro 3? I'd like to use Workspaces as part of the development and see that they're not yet supported. Is this likely require a "rename some stuff" pass or something more involved to get support for Workspaces and inspect?

tony.kay23:05:23

Fulcro 3 is still a month or more out

tony.kay23:05:30

not even alpha yet

tony.kay23:05:01

I’d recommend 2…3 will be pretty strongly API compatible.

👍 8
grzm23:05:06

💯 on the full namespace names in Fulcro 3 🙂

tony.kay23:05:29

you speaking of domain-based namespace naming?

tony.kay23:05:49

yeah, I’m an old-hat Java guy…when I started in Clj it seemed the community here wasn’t doing that, so I wanted to “fit in”…but they are just a general good idea

tony.kay23:05:24

so, when I wanted “safe new names”, going to those seemed better than fulcro3.client...

grzm23:05:44

I completely agree. It's one of the things I think Java really got right. Didn't even fully realize what I was missing in Perl and Ruby.

tony.kay23:05:47

or fulcro-next 😜

grzm23:05:58

Don't you mean fulcro.next?

tony.kay23:05:07

ah, right 🙂

tony.kay23:05:29

I could code it all in one ns if you’d prefer 😉

grzm23:05:53

Oh, that'd be nice! 😛

tony.kay23:05:47

but then I’d have to name it core

tony.kay23:05:21

well, I guess I could put some stuff in util