Fork me on GitHub
#fulcro
<
2018-11-12
>
eoliphant00:11:50

hi I'm having a weird router problem. have a pretty basic routing tree setup,in a root component that just has a menu bar, and the router component. route-to mutations work fine in response to onClick's on the menu. However, when I run the exact same mutation from 'inside' one of the pages, I get a Cannot route: Unknown Screen error. The router data in the DB appears correct fulcro.client.routing/current-route is set to the ident of the expected page, etc. Not sure if it's some sort of timing issue?

noonian03:11:30

Has anyone seen issues using fulcro.client.dom in cljc files? I’m seeing class keywords with multiple classes like :.foo.bar.baz cause a syntax error but works when wrapped in #?(:cljs ...) I’m using 2.6.15

sooheon03:11:48

You need to pull in fulcro.client.dom-server :as dom for clj side of things

noonian03:11:52

Got it. Thanks. I’m surprised it’s worked so far without using the conditional require!

tony.kay05:11:01

@eoliphant That error means the first component of the ident you set does not match any of the keywords in the router's declaration...so it doesn't know what component to use for the screen

eoliphant15:11:24

Hey Tony, yeah I've seen that before when things were misconfigured. But the weird thing is that this seems to be happening based on where the mutation is invoked, not the ident. exact same one works in one place but not the other. Running our for a sec, will create a stripped down case when i get back

tony.kay16:11:16

Are you basing your mutation on ref or something? That's the only bit of info that is local to invocation

eoliphant16:11:58

ok, just got back. and of course my simple example works fine lol. let me dig in

eoliphant17:11:08

ugh, nvm, i'd put idents on the page components, removing them fixed it

tony.kay17:11:16

so, you want idents on the page components...but they MUST return the right thing

tony.kay17:11:30

if you don't put idents on them and then use any one of them with load, then normalization won't work

tony.kay17:11:54

on initial state, the union component (in the router) is used for normalization, but is isolation the screens are

tony.kay17:11:06

if you don't load against any of them, then it is fine to not have idents on them

eoliphant18:11:01

hmm ok, then this is back to weird

(defsc HomePage [this {:keys [router/page db/id]}]
  {:query         [:db/id :router/page]
   ;:ident         (fn [] [page id])
   :initial-state {:db/id 1 :router/page :PAGE/home}}
  ...
          (sui/Button {
                       ...
                       :onClick #(prim/transact! this `[(r/route-to {:handler :kits})])} "Get Started"))))

The mutation works fine in that example, but blows up when I uncomment the ident. little confused about the 'ident-generator' on the defrouter in this case.

wilkerlucio13:11:16

@tony.kay hey, I'm having issues with incubator 0.0.15, after bump my build doesn't compile anymore

thheller13:11:38

eek. that error needs some formatting 😛

👍 4
wilkerlucio13:11:23

but in the end seems like some missing specs

wilkerlucio13:11:42

but ther specs being complained about seem to be there :thinking_face:

thheller13:11:43

try shadow-cljs clj-repl then (require 'fulcro.incubator.pessimistic-mutations) to get the "clean" error without all the noise

wilkerlucio13:11:38

[1:0]~shadow.user=> (require 'fulcro.incubator.pessimistic-mutations)
CompilerException java.lang.Exception: Unable to resolve spec: :fulcro.client.primitives/component-class, compiling:(pessimistic_mutations.cljc:18:1)

thheller13:11:56

hmm yeah that spec doesn't seem to exist?

wilkerlucio13:11:11

it exists, Cursive is able to navigate to it

wilkerlucio13:11:39

I can see it on primitives

wilkerlucio13:11:41

(s/def ::component-class
  (s/with-gen component-class? #(s/gen #?(:clj  #{(with-meta {} {:component true})}
                                    :cljs #{#js {:prototype #js {:fulcro$isComponent true}}}))))

thheller13:11:53

indeed. seems to be recent. my local git checkout didn't have it

wilkerlucio13:11:06

I'm using latest fulcro 2.6.15

thheller13:11:34

check ( "fulcro/client/primitives.cljc") if you actually do 🙂

wilkerlucio13:11:59

I checked by navigating in Cursive, so I'm viewing from the jar, but let me try that anyway

pserrano13:11:23

I'm getting lots of console errors as the app first loads, and it doesn't connect After making any modification to the code, the app soft reloads and starts without errors

pserrano13:11:53

react.development.js:207 Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.
warningWithoutStack @ react.development.js:207
warning @ react.development.js:630
createElementWithValidation @ react.development.js:1632
(anonymous) @ core.cljs:3872
(anonymous) @ core.cljs:3914
cljs$core$apply @ core.cljs:3887
fulcro$client$primitives$create_element @ primitives.cljc?rel=1542026469692:695
fulcro$client$primitives$element_factory__delegate @ primitives.cljc?rel=1542026469692:720
fulcro$client$primitives$element_factory @ primitives.cljc?rel=1542026469692:706
G__10384__2 @ core.cljs:2010
G__10384 @ core.cljs:1999
fulcro$client$primitives$render_fn @ primitives.cljc?rel=1542026469692:1955
fulcro$client$primitives$parse_fn__1 @ primitives.cljc?rel=1542026469692:1977
fulcro$client$primitives$parse_fn @ primitives.cljc?rel=1542026469692:1968
(anonymous) @ primitives.cljc?rel=1542026469692:1996
fulcro$client$impl$protocols$add_root_BANG_ @ protocols.cljc?rel=1542026469232:17
(anonymous) @ primitives.cljc?rel=1542026469692:2466
fulcro$client$primitives$add_root_BANG_ @ primitives.cljc?rel=1542026469692:2453
(anonymous) @ primitives.cljc?rel=1542026469692:2460
fulcro$client$primitives$add_root_BANG_ @ primitives.cljc?rel=1542026469692:2453
fulcro$client$initialize @ client.cljc?rel=1542026473203:227
fulcro$client$mount_STAR_ @ client.cljc?rel=1542026473203:281
(anonymous) @ client.cljc?rel=1542026473203:286
fulcro$client$mount @ client.cljc?rel=1542026473203:168
(anonymous) @ core.cljs:4473
(anonymous) @ core.cljs:4473
cljs$core$swap_BANG_ @ core.cljs:4458
net$molequedeideias$front_proxy$core$main @ core.cljs?rel=1542028070338:17
(anonymous) @ (index):13
react-dom.development.js:55 Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
    at invariant (react-dom.development.js:55)
    at createFiberFromTypeAndProps (react-dom.development.js:9988)
    at createFiberFromElement (react-dom.development.js:10009)
    at reconcileSingleElement (react-dom.development.js:13034)
    at reconcileChildFibers (react-dom.development.js:13091)
    at reconcileChildren (react-dom.development.js:13513)
    at updateHostRoot (react-dom.development.js:13808)
    at beginWork (react-dom.development.js:14492)
    at performUnitOfWork (react-dom.development.js:17014)
    at workLoop (react-dom.development.js:17054)

wilkerlucio13:11:42

this looks like you are trying to render something invalid

pserrano14:11:56

I was actually defonceing a component and exporting the ui-component in my app.client ns

pserrano14:11:17

Switching both for my root component solved the errors

pserrano14:11:38

And it now connects correctly

wilkerlucio13:11:58

@thheller actually, when I do that it doesn't come, the file from the resource doens't have the spec

wilkerlucio13:11:25

I'll try remove the dep from .m2, how that can happen?

wilkerlucio14:11:04

removing from m2 to force reinstall didn't solved it

wilkerlucio14:11:12

worked after lein clean + rm -rf target :man-shrugging:

tony.kay16:11:09

If you had built an uberjar the clj side of things can pull from target...which makes all sorts of crazy stuff happen. Got bit by that myself the other day

thheller14:11:29

maybe older AOT files?

thheller14:11:51

lein sometimes also copies all files to target/classes when building uberjars for example

thheller14:11:20

that source path is usually used before jars from .m2

wilkerlucio14:11:43

maybe, and thanks for the resource trick, I'll remember that one 🙂

iamyemeth14:11:07

Anyone here using fulcro at work? If so how did you convince management to try it or why did management pick it?

wilkerlucio14:11:18

man, I'm currently in a big crusade to convert a re-frame app to Fulcro, wasn't easy to sell, I had to use some new pieces opportunity to start introducing it bit by bit, demonstrating advantages and improving the tooling while doing it, but after a lot of work we are now convinced to give it a try and started porting everything. its hard to sell at first because the real gains come from mid/long term, after people understand the power of the architecture then they see the reasons why they have learn about all these "complicated things" that in the end are just good practices to keep the system sane when things get big

wilkerlucio14:11:11

I'm gonna do a talk at the conj this year where I'm going to summary the path we took and demonstrate the gains we have over time by adopting these ideas, maybe this can help you out with the selling once its online 🙂

👍 4
iamyemeth14:11:34

Awesome, I'll definitely keep an eye out for it

iamyemeth14:11:57

I feel like it becomes easier to sell when there is more usage. I don't know too many companies who are using fulcro in production that I could point too

iamyemeth14:11:57

re-frame definitely has a lot of traction, but I feel like it starts lacking in the mid/long term like you mentioned

iamyemeth14:11:28

What was your experience like getting more junior developers up to speed?

wilkerlucio15:11:31

there is a learning curve there, but with time and explaining they get there, when I started doing it here I was the only one that knows about it, but after 5 months we have already 5 teams that know how to navigate and can do a lot without supervision, after a while some of then are enjoying and having fun with it

miridius14:11:03

One piece of feedback on the new fulcro leiningen template (and same for the old one), rather than having your compiled js files output to resources/public/js, I find that it's better to put them somewhere in your target dir, and then add that to the classpath by adding it to the :resource-paths list in project.clj. As long as they follow the same path structure as your resources dir they should still be picked up by the http server, and that way you have a separation of what are actual static project resources in the resources dir vs the ephemeral, compiled build outputs in the target dir.

kirill.salykin16:11:09

Please advice, is it possible to check what data-fetch/load loaded and update db only if it is nil for instance? the problem I am trying to solve - every minute ask server if user is still signed in everything seems to work with this approach:

wilkerlucio16:11:03

you can use the :target from the load to dump the loaded data into a different place that's not connected with your UI, then using a :post-mutation you check the value in this place, and then you can check any logic you want and then move the data to the correct place when makes sense

kirill.salykin16:11:11

interesting… thanks

wilkerlucio16:11:06

data juggling 🙂

🙂 4
kirill.salykin16:11:20

(js/setInterval #(df/load app
                                                  :current-user
                                                  login/UserSettings
                                                  {:params   {}
                                                   :parallel true})
                                        (* 1000 60))
the only issue that login screen flickrs, because of current-user update

tony.kay16:11:16

See the flicker-free stuff in incubator...also would not use parallel there, since you could end up with many in flight and DOS yourself

tony.kay16:11:49

turn off the marker if you don't want the load marker (which is causing this flicker)

tony.kay16:11:56

:marker false

tony.kay16:11:16

I would switch that to the default, but it is an old legacy default that a lot of app could rely on

kirill.salykin09:11:54

thanks, but seems I need to disable :ui/loading-data and :marker false doesnt change this behaviour

tony.kay16:11:43

what do you mean doesn't change it? You mean the root level loading-data?

tony.kay16:11:04

don't even query that...use named load markers instead...e.g. you could even use a component's ident as the marker ID, or your own name for a load marker that you apply to a group of your loads if you want "this kind of activity"...then query the load marker table directly

kirill.salykin16:11:41

I expected something different from marker, now it totally makes sense

kirill.salykin16:11:55

and yes, giving it a name helps

wilkerlucio16:11:22

@tony.kay I'm trying to use the new SM format :state {:action! {::uism/handler (fn [env] ...)}} but I keep getting ERROR [fulcro.incubator.ui-state-machines:?] - Did not find a handler for :filling-info

tony.kay16:11:58

and ::uism/states

tony.kay16:11:10

so, should just be spelling

wilkerlucio16:11:25

I followed the template:

wilkerlucio16:11:26

::uism/states {:initial { :thing-happened! {::uism/event-predicate (fn [env] ... true)
                                            ::uism/target-state :next-state
                                            ::uism/handler (fn [env] env) }}
               :next-state { ... }
               ...

wilkerlucio16:11:38

looking at this my setup seems correct, is the template ok?

wilkerlucio16:11:02

this is my current code:

wilkerlucio16:11:03

(uism/defstatemachine finance-machine
  {::uism/aliases {:visible?                          [:dialog :ui/show-finance-simulation?]
                   :account.financing/minimum-payment [:form :account.financing/minimum-payment]}
   ::uism/plugins {}
   ::uism/states  {:initial
                   {::uism/handler
                    (fn [env]
                      (-> env
                          (uism/set-aliased-value :visible? true)
                          (cond->
                            (not (uism/alias-value env :account.financing/minimum-payment))
                            (uism/load-actor :form {:update-query db.h/remove-lazy}))
                          (uism/activate :filling-info)))}

                   :idle
                   {:show!
                    {::uism/target-state :filling-info

                     ::uism/handler
                                         (fn [env]
                                           (-> env
                                               (uism/set-aliased-value :visible? true)))}}

                   :filling-info
                   {:hide!
                    {::uism/target-state :idle

                     ::uism/handler
                                         (fn [env]
                                           (-> env
                                               (uism/set-aliased-value :visible? false)))}

                    :update-downpayment!
                    {::uism/handler
                     (fn [env]
                       env)}}}})

wilkerlucio16:11:22

I can confirm my state machine is in :filling-info, and I get the error when I try to trigger :hide!

wilkerlucio16:11:15

looking at the full example now, seems like the template is missing the ::uism/events key

wilkerlucio16:11:11

yup, just confirmed, the template is missing it

tony.kay17:11:50

yeah, the CARD is right, but the docs were wrong

wilkerlucio17:11:54

question, if I provide both ::uism/events and ::uism/handler, the handler will be a fallback or it overrides ::uism/events?

tony.kay17:11:08

generic-handler is the one for events

tony.kay17:11:25

so a top-level handler will override

wilkerlucio17:11:46

humm, so a custom one will override, I think the other way around would be more useful

wilkerlucio17:11:54

so this could be a fallback for non-defined events

wilkerlucio17:11:10

because if you like to have full control, you can just use only the handler

wilkerlucio17:11:18

but handler + events only makes sense as a fallback I think

tony.kay17:11:23

complex semantics

tony.kay17:11:39

IF you define a handler, it is up to you. period

tony.kay17:11:46

If you don't , then it is events.

tony.kay17:11:01

Making them mix is not something I desire without very specific and easy to udnerstand semantics

wilkerlucio17:11:34

I'm thinking about the instrospectable approach, would be nice to have information from defined events by hand, but still have the option to write a fallback

tony.kay17:11:38

also, the event structure is meant to be machine readable..if you mix you're losing the point

tony.kay17:11:59

I'd rather make a catch-all event

wilkerlucio17:11:14

I think that works too, would be nice to have 👍

tony.kay17:11:24

::uism/unknown-event or something

wilkerlucio17:11:35

::uism/default-event

tony.kay17:11:38

we could even default that to something that logs

tony.kay17:11:57

"got event X in state Y but wasn't expecting it." Just in debug/dev mode though

veddha18:11:51

If try to follow http://book.fulcrologic.com/#_cascading_dropdowns , but I end up with (No method in multimethod 'read-root' for dispatch value: :models" , :type "class java.lang.IllegalArgumentException")

tony.kay18:11:37

Did you require that in your server?

tony.kay18:11:55

multimethods (which is what defquery gens) depend on require

veddha18:11:39

in server_main.clj?

tony.kay18:11:24

there and in user (for dev mode)

veddha18:11:59

1 more thing, I followed http://book.fulcrologic.com/#_triggering_the_load ,but when i restart server and reload browser, i still not get the :current-user

claudiu18:11:10

is there any way to disable the in-place load markers for the app ?

tony.kay18:11:35

sure, make your own load function that passes that parameter always

claudiu09:11:52

Remembering that you mentioned a while ago that the only reason it's true is for compatibility. The targeted stuff is nice and plays well with abort and doing some caching. Looks like it would be pretty easy to add a config option to new-fulcro-client that would default to true, and people could opt-out there. Would you be interested in a PR with this ?

tony.kay15:11:43

hm. that’s not a bad idea. We could even default it to false that way, and leave a breaking change notice on how to fix it when you upgrade…I don’t usually like doing that, but in this case “false” is really just the right value….true should be a deprecated value, and everything else should go to the marker table.

tony.kay16:11:16

or just make a make-fulcro-client that we document in the book, and drop docs for the old one so ppl don’t even know about it 🙂

tony.kay16:11:51

that way it doesn’t break old, and could get rid of the boolean altogether

tony.kay16:11:10

If you’re willing to do the work, here’s what I think should be done: 1. Create make-fulcro-client that has same API as new-fulcro-client, but sets a reconciler flag for load-markers to false. 2. Change load to look for the default load marker from there 3. Change new-fulcro-client to pass “true” for this option, and call make-fulcro-client. Add deprecation notice to new-fulcro-client, and move docstring to new function 4. Update the book to the new function name with a NOTE that older versions of Fulcro called it new-fulcro-client 5. Update the book’s load marker chapter to not even mention true, but instead only mention named load markers. 6. check for other references in the book to the use of “true” for load marker in text and code.

tony.kay16:11:43

probably should review the videos to see if “true” is talked about in them…and add comments in the description, or re-record them.

tony.kay16:11:40

would love the help

claudiu17:11:52

Yep sure, would love to help with this one. The approach you mentioned is pretty clear. Will start work on it tomorrow :)

claudiu18:11:37

oky 🙂 will go with that 🙂

pserrano18:11:15

fulcro-todomvc project from github doesn't connect with fulcro-inspect chrome's tool. Any ideas?

wilkerlucio19:11:48

@tony.kay I'm curious about the reasoning around ::uism/event-predicate, what did you see when you decided to have a custom handler instead of just a regular if in the handler?

tony.kay00:11:57

Because you might want to block an event for multiple states…e.g. ::value-changed while “busy”. Without the predicate you’d have to do it in every handler…AND there’d be no way to prevent ::value-changed from affecting state (which it does automatically)..the predicate will prevent that too.

currentoor19:11:09

@patrickcms that project is pretty old, probably out of date or something

pserrano19:11:01

Maybe What is odd to me is the fact that de app runs and works but I can't see it's database

claudiu19:11:48

somethigs a bit off there 🙂 seems like fulcro inspect is in the project.clj https://github.com/fulcrologic/fulcro-todomvc/blob/master/project.clj#L65

pserrano19:11:08

Yes, it seems to me that it should work nice and pretty

tony.kay00:11:02

too old a version

tony.kay00:11:15

CTRL-F for that version, since it doesn’t use the plugin in chrome at all

pserrano19:11:40

Youtube's guide, part 1: command

lein new fulcro demo 
doesn't come with devcards template as the video shows

tony.kay19:11:01

Yeah, I’m going to just have to add comments on the videos

tony.kay19:11:06

don’t have time to re-record them

pserrano20:11:40

Alright, thanks!

tony.kay21:11:17

thanks for the note…too many things for one person to keep track of in their spare time

tony.kay19:11:14

comment updated

tony.kay23:11:15

Released 0.0.16 of Incubator…the jar was accidentally including source twice…that is fixed now, so it should work better with Cursive.

20