This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-12
Channels
- # announcements (2)
- # beginners (104)
- # cider (2)
- # cljs-dev (26)
- # cljsrn (1)
- # clojure (125)
- # clojure-dev (27)
- # clojure-italy (24)
- # clojure-nl (24)
- # clojure-russia (4)
- # clojure-spec (10)
- # clojure-uk (83)
- # clojurescript (18)
- # code-reviews (102)
- # community-development (14)
- # core-async (18)
- # cryogen (11)
- # cursive (15)
- # datomic (16)
- # emacs (6)
- # figwheel-main (6)
- # fulcro (142)
- # graphql (5)
- # jobs (5)
- # jobs-discuss (18)
- # kaocha (1)
- # keechma (1)
- # leiningen (20)
- # luminus (1)
- # mount (5)
- # pedestal (4)
- # reagent (17)
- # reitit (8)
- # shadow-cljs (29)
- # tools-deps (19)
- # vim (108)
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?
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
Got it. Thanks. I’m surprised it’s worked so far without using the conditional require!
@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
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
Are you basing your mutation on ref
or something? That's the only bit of info that is local to invocation
if you don't put idents on them and then use any one of them with load, then normalization won't work
on initial state, the union component (in the router) is used for normalization, but is isolation the screens are
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.@tony.kay hey, I'm having issues with incubator 0.0.15, after bump my build doesn't compile anymore
but in the end seems like some missing specs
but ther specs being complained about seem to be there :thinking_face:
try shadow-cljs clj-repl
then (require 'fulcro.incubator.pessimistic-mutations)
to get the "clean" error without all the noise
[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)
it exists, Cursive is able to navigate to it
I can see it on primitives
(s/def ::component-class
(s/with-gen component-class? #(s/gen #?(:clj #{(with-meta {} {:component true})}
:cljs #{#js {:prototype #js {:fulcro$isComponent true}}}))))
I'm using latest fulcro 2.6.15
I checked by navigating in Cursive, so I'm viewing from the jar, but let me try that anyway
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
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)
this looks like you are trying to render something invalid
I was actually defonceing a component and exporting the ui-component in my app.client ns
@thheller actually, when I do that it doesn't come, the file from the resource doens't have the spec
I'll try remove the dep from .m2
, how that can happen?
removing from m2 to force reinstall didn't solved it
worked after lein clean
+ rm -rf target
:man-shrugging:
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
lein sometimes also copies all files to target/classes
when building uberjars for example
maybe, and thanks for the resource trick, I'll remember that one 🙂
Anyone here using fulcro at work? If so how did you convince management to try it or why did management pick it?
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
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 🙂
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
re-frame definitely has a lot of traction, but I feel like it starts lacking in the mid/long term like you mentioned
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
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.
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:
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
interesting… thanks
(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
updateSee the flicker-free stuff in incubator...also would not use parallel there, since you could end up with many in flight and DOS yourself
turn off the marker if you don't want the load marker (which is causing this flicker)
I would switch that to the default, but it is an old legacy default that a lot of app could rely on
thanks, but seems I need to disable :ui/loading-data
and :marker false
doesnt change this behaviour
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
I expected something different from marker, now it totally makes sense
and yes, giving it a name helps
thanks
@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
::uism/handler @wilkerlucio?
I followed the template:
::uism/states {:initial { :thing-happened! {::uism/event-predicate (fn [env] ... true)
::uism/target-state :next-state
::uism/handler (fn [env] env) }}
:next-state { ... }
...
looking at this my setup seems correct, is the template ok?
this is my current code:
(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)}}}})
I can confirm my state machine is in :filling-info
, and I get the error when I try to trigger :hide!
looking at the full example now, seems like the template is missing the ::uism/events
key
yup, just confirmed, the template is missing it
PR with fix to docs: https://github.com/fulcrologic/fulcro-incubator/pull/9/files
question, if I provide both ::uism/events
and ::uism/handler
, the handler will be a fallback or it overrides ::uism/events
?
humm, so a custom one will override, I think the other way around would be more useful
so this could be a fallback for non-defined events
because if you like to have full control, you can just use only the handler
but handler + events only makes sense as a fallback I think
Making them mix is not something I desire without very specific and easy to udnerstand semantics
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
also, the event structure is meant to be machine readable..if you mix you're losing the point
I think that works too, would be nice to have 👍
::uism/default-event
sounds good
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")
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
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 ?
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.
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 🙂
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.
probably should review the videos to see if “true” is talked about in them…and add comments in the description, or re-record them.
Yep sure, would love to help with this one. The approach you mentioned is pretty clear. Will start work on it tomorrow :)
fulcro-todomvc project from github doesn't connect with fulcro-inspect chrome's tool. Any ideas?
@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?
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.
@patrickcms that project is pretty old, probably out of date or something
Maybe What is odd to me is the fact that de app runs and works but I can't see it's database
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
Youtube's guide, part 1: command
lein new fulcro demo
doesn't come with devcards template as the video shows