This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-11
Channels
- # adventofcode (129)
- # architecture (10)
- # beginners (163)
- # boot (1)
- # cider (34)
- # cljs-dev (9)
- # clojure (210)
- # clojure-austin (11)
- # clojure-czech (2)
- # clojure-gamedev (1)
- # clojure-greece (67)
- # clojure-italy (2)
- # clojure-russia (8)
- # clojure-spec (36)
- # clojure-uk (54)
- # clojurescript (87)
- # cursive (12)
- # data-science (6)
- # datomic (13)
- # devcards (4)
- # editors (2)
- # emacs (34)
- # figwheel (6)
- # fulcro (147)
- # graphql (17)
- # lumo (54)
- # off-topic (37)
- # om (11)
- # onyx (7)
- # parinfer (10)
- # random (1)
- # re-frame (13)
- # ring (10)
- # ring-swagger (2)
- # sfcljs (1)
- # shadow-cljs (1)
- # spacemacs (32)
- # test-check (4)
- # unrepl (84)
How make fulcro working with datomic as backend db, How to use om next's
:remote
, Do need to convert ast to datalog?@tpliliang The developer's guide covers how to talk with remotes. The story for using Datomic is identical to Om Next's.
@tony.kay Yes, I just read the TodoMvc, the comment say:
; Datomic's pull can handle Fulcro query syntax
Why doesn't this
(f/ui-form-field nil
(f/ui-input #js {:placeholder "aaaaa...."})
(f/ui-label #js {:pointing nil} "hahahaha!"))
work in semantic-ui-wrapper?the code in http://react.semantic-ui.com
<Form.Field> <input type='text' placeholder='First name' />
<Label pointing>Please enter a value</Label>
</Form.Field>
@tony.kay I just noticed something using the ptransact!
, seems like operations after the first are not getting the ref
on the mutation, is that expected?
component
is also missing
@tony.kay what you think about merging the tx response in the same level as the ref
that initialized it? what i"m seeing here is that, when some server error occurs (for any reason) it returns an om.next/error
under the value of the mutation
if I could just read that, would be easy for me to detect an error happened and I could display some error information to the user
right now when I add the returning
my output it just goes away (not sure why, but yeah, that's on my side), but still, if we could inject that in the same ref of the component that triggered the mutation, would be great, what you think?
@tpliliang That library is a simple, largely machine-generated, set of functions that simply call the underlying react semantic UI classes. I wrote it for other's convenience. I do not directly support it. Some things to try: :pointing true
?
It's a straight wrapper, so you should be able to look at the code and see if the wrapper is wrong.
@wilkerlucio So, ptransact! rewrites the transaction so that it can run the next step (from the reconciler) when networking completes on the prior one. I guess it probably should not lose the ref and component...could pass those along as metadata on the load marker underneath I guess.
On the returning
. Yeah, error handling should be improved somehow. It goes away because the merge uses the query, and the query doesn't expect an error key.
@tony.kay I remember in past, the mutation result used to be merged at the root of the db
that seemed to stop happening on 2.0, not sure if was intentional
it was intentional...merges should be handled by a merge routine, or the new returning support
but having it on the root is not that useful anyway because it could potentially be overwritten by someone else calling the same operation, so, it's not reliable enough
I would love to see it merged back into the ref that called the operation (when there is one, which is most of the time)
So, my thought was that if you have the possibility of an error, you'd include that as part of the query on the entity, and then the server could just return it normally...nothing needed in the library. I'm open to other suggestions.
the problem on that is it can't be generalized properly, unless you normalize in the end on the server, but requires server changes to adapt to it
in my case my errors are pretty regular, if there is an error, the om.next/error
comes there (and that's from om parser, it automatically does that)
since I'm in a microservices architecture, I have to keep waiting for errors to happen anytime for various reasons
when I tried to add the "returning", my server started outputting nothing, I have to investigate why, might be something about how the om parser works, I have to play more with the parser on mutation error scenarios to understand it better
so what exactly is your proposal? "returns an error" is vague. You suggesting a specific return value, or some exception capturing?
well, my proposal is that we always merge the mutation result on the ref
or give an option to do that
I mean, if nothing said, just literally merge the result on the ref, for example:
(prim/transact! this [:some "ref"] [(call/operation {})]
db before:
{:some {"ref" {:foo "bar"}}}
db after server return:
{:some {"ref" {:foo "bar", call/operation {:result "data"}}}}
this way, any operation result could be checked upon
without having to declare a structure and match client/server
then you're dispatching on the mutation symbol and can do anything you'd like to state
not sure what you mean by mutation merge, I guess I never used that, can you tell me more?
hahaha, sure, let me check it there
I need to read those again, it's a been a long time
http://fulcro.fulcrologic.com/guide.html#!/fulcro_devguide.H12_Mutation_Return_Values
(I think last time I read those it was Untangled still XD)
Although you do bring up an interesting point that I had not thought about: that you might want to use returning
and the mutation merge trigger...both should probably happen, and I have not tested that scenario
and it should have a predefined order so it is predictable: returning first, then mutation-merge
cool š
@tony.kay I was just trying to use the mutation-merge
, but there is one problem, I don't have the ref
available there to merge where I want =/
Not sure I understand why you need it. The mutation affects something in your db...and you know what that is. You had to identify "which" thing or the mutation can't know what to affect...not sure why you cannot derive it.
in this case for example, I have many "cards", and the card triggers it, but from the information that comes from the server I can't identify to which card the operation hapenned
and I might have operations on multiple cards running at the same time
I feel like the ref
is a strong information that should be present pretty much everywhere
because it enables us to know who triggered the given operation
seem fragile to me. Mutations are meant to be generalizations, and ref
ties you to a specific UI concern. You could easily refactor your program and have tons of things break because you moved something to a callback in a different component that relied on a ref.
I mean, of course I can keep throwing ids around, but the framework already have that information, feels like double work if I have to keep sending it
so, my personal preference is to throw IDs around, because then all of the information is encapsulated in the mutation. Makes it fully reusable, relocatable, etc. Yes, it's a little more typing, but that's rarely my concern in a library unless I'm writining a DSL macro.
the ref is also strong, I don't have refs like that, if a component is on a ref, it should remain there, I mean, when I transact the ref
goes with it, and I never change the ref of a component once it's on the page
so seems like an obvious target to me to re-use that information knowing the caller will be able to access it (after all, that's where it came from)
you really want a general function-like thing that has to rely on the context in which it is called???
I mean, Fulcro also uses refs for generic operaitons like set-props, and here I'm also talking about generic operations (generic error handling)
Those are exceptions that are tightly documented as for :ui
props, local to a component only
I'm thinking: someone triggered an op, and i have an error, so I want to give that error information back to the one who called it
this is very generic, could apply o anyone, and everyone has the ref
to get back to
sure, getting the error back accessible to the one who called is the main issue
I though of refs, but if you have other way to manage, I'm all ears (maybe eyes are more correct here? hehe) š
I have some stuff to take care of at the moment...back in a bit. I'll mull it over. David Nolen had some plans around this that he never implemented. They were making the error visible on the graph in a transient fashion (the errors would be there for one render cycle, so to speak, and you'd grab them if you needed to process them). That way they didn't end up in state unless you put them there from the component.
I've been doing something that I liked here regarding load errors
Basically, the merge would merge them at the spot in the graph where they happened...but that was for queries
yeah, for load I have a good story here
in pathom, when you add the error plugin, attributes with errros get maked on the db, and the errors thenselves come in a separated map in the result root
this map contains {[path] error-detail}
but on my network, I just pull those errors up, so they end up in the same level as the field with error, eg:
{:query {:item :com.wsscode.pathom/reader-error}
:com.wsscode.pathom.core/errors
{[:query :item] {:error "some error"}}}
turns in:
{:query {:item :com.wsscode.pathom/reader-error
:com.wsscode.pathom.core/errors {:item {:error "some error"}}}
this makes really easy to display errors on the client, if there is an error, the detail is right there
and this is what triggered my idea os pulling the mutation errors to the same place, to make those as accessible as the load errors
sure, have a good one š
for starting a new project, does it make more sense to use the 2.0 branch of the fulcro-template repo, or lein new fulcro app
?
@adamvh I think the lein template was already updated to version 2, so lein new fulcro
should be fine
hey all, having a tough time getting something like the following query to work in one of my fulcro components my state initial state in my root component looks something like:
{:current-user {:db/id 1
:organizations [[:organization/by-id 200] [:organization/by-id 201]]}
:organizations/by-id {200 {:db/id 200
:name "Test Org"}
201 {:db/id 201
:name "Test Org"}}
Iām trying to pull the name
and db/id
of each of the current userās organizations I think what Iām trying to do inside of my component is something like a parameterized join using idents?
I tried subbing in idents in the relevant places from a parameterized join example, and my query ended up looking like the following:
[({[:organizations/by-id '_] [:name :db/id]} {[:current-user '_] [:organizations]})]
unfortunately, getting an invalid-expression
error, and I canāt seem to figure out why. any tips on how youād structure a query to pull out data shaped that way?
thanks in advance for any helpHello! From Dev Guide (http://fulcro.fulcrologic.com/guide.html#!/fulcro_devguide.O01_Forms_The_Basics): >quote NOTE: The Forms support described in section O is still described with defui. There is ongoing work to add a simpler method of forms support to 2.0. Once that evaluation is complete these sections will either be updated or replaced with the new mechanism. There is no plan to remove this form support, but the advent of Clojure spec is leading us to what we think might be a better way of doing it. Is there any timeframe for the reworked forms in 2.0?
@piotrek You can look at the current proposed version on the forms-2.0 branchā¦lots to do right now, but would appreciate feedback
https://github.com/fulcrologic/fulcro/blob/forms-2.0/src/cards/fulcro/client/forms_state_cards.cljs
nope, this is local, if thatās what you mean. no remotes or external data sources for now
so, parameters are not generally what you want. Just shape your data for the structure of the UI
I donāt actually. I was going to break everything up into pieces like that once I got the overall query working
then you can technically embed that anywhere with the query [{[:current-user '_] (prim/get-query User)}]
@adamvh The template is probably going to be renamed and turned more into a sample project. Itās too much to grok all at once, so the lein template is prob a better place to start.
yeah, the lein project has been a much better jumping-off point; i can get cards going and make UI elements really easily
although i haven't watched them; electing to try getting my feet dirty with my untangled-era knowledge before watching them š
Hi! I am trying to find a correct way to obtain the current route to highlight the current menu item in the top navigation bar (I am sorry for silly question - I am still learning). I have this router:
(defrouter TopRouter :top-router
(ident [this {:keys [screen]}] [screen :top])
:main MainScreen
:settings SettingsScreen)
that I use in my Root
:
(dom/div nil
(ui-top-menu)
(ui-top-router top-router-data))
What is the idiomatic way to query in TopMenu
for the current route to get a value like :main
or :settings
?@piotrek when you have this kind of things: a parent that knows a selection, and the children where one of those are selected. What we usually do is send the some info the the selected item as a computed
prop
Fulcro 2.0.0-beta6 on clojars. A few minor bug fixes. Fulcro template updated to 2.0 as well.
@wilkerlucio I think here itās not a parent that knows the current selection but rather a sibling component (TopRouter knows that, not Root)
you donāt have to use bootstrapā¦those are just wrapper classes, but it is a working example
@piotrek sure, you can send the props via computed to that too
in a list case it would be something like this:
(for [i items]
(some-child (cond-> i (= i selected-item) (om/computed {:ui/selected true}))))
http://fulcro.fulcrologic.com/guide.html#!/fulcro_devguide.N15_Twitter_Bootstrap_Components/nav-tabs
you can also use computed, as Wilker suggests. These examples use state as reusable components. The idea is that HTML5 routing would happen out of context of a parent/child relationship, and you might have to update a number of GUI things all at once.
one could argue that using state in more than one component to stand for the same thing is duplication (and Iād agree). Using link queries is another alternativeā¦query for the routerās state from the router table and ālookā is the better way perhaps
fulcro.client.routing/routers-table
is a var holding the keyword of the router table name. So a query like this: [ [r/routers-table :your-router-id] ]
will get you any routerās dataā¦
Oh, so it looks that I would need to maintain a sub-graph holding the currently selected screen, independently of the [:fulcro.client.routing.routers/by-id :top-router :fulcro.client.routing/current-route]
path
OK, so I went with the ident based query: [{[r/routers-table :top-router] [::r/current-route]}]
and it binds current-route local var to a value like {:screen :main}
which is the value from [:main :top]
sub graph (a state of my MainScreen). Is there a simple way to unpack the :main
value from it? (I am using :screen in the TopRouter ident)