Fork me on GitHub
#fulcro
<
2021-09-20
>
genekim03:09:20

I’m trying to do something similar to what Bootstrap Fixed Nav does, where the menu / nav items are always visible, floating above the rest of the stuff that scrolls underneath. https://getbootstrap.com/docs/3.4/examples/navbar-fixed-top/ I notice that there’s a Sticky Semantic-UI wrapper, that I think could do something similar — but what do you pass as context? (In the React examples, you’d pass contextRef, but I have no idea where you get one of those.). https://codesandbox.io/s/175tc?module=/example.js&amp;file=/example.js:139-145 Thanks!

Jakub Holý (HolyJak)08:09:52

FYI I have published a new short Fulcro troubleshooting demo https://youtu.be/KX0ePXIEDeU

👍 2
Jakub Holý (HolyJak)15:09:58

Fun fact: I picked up Grokking Fulcro again (https://www.youtube.com/watch?v=_aaI7yB29R0&amp;list=PLVi9lDx-4C_TBRiHfjnjXaK2J3BIUDPnf&amp;index=4 in this case) and immediately it started answering my question about the importance of ruters for app performance 🙂

hadils15:09:27

Hi! I need to send an Authorization token to my remote (standard RAD implementation). The problem is that the access token to send is retrieved asynchronously, so just putting it in the request middleware is not really an option. I don’t know what to do here. Any suggestions?

Jakub Holý (HolyJak)16:09:35

I do not have the answer but am sure it has been discussed in the past. Perhaps the clojurians log or zulip mirror can help you, if you search #fulcro for "token"?

tony.kay16:09:12

The access token is something you need to get via either a remote, or an external js API. So, one thing you can do is create a remote for talking to the auth system (called :auth, maybe?). Use the mock-remote pattern that the book uses for the examples (see book source, and fulcro mock-remote). You can create a pathom parser on the client so that this "remote" isn't really remote, and then the pathom parser on the client side works fine with async results. Then you can do a sequence for your auth where you do the auth to get the token, then reset the other remote to know what it is (or put it in a global atom to begin with)

hadils16:09:57

Thanks. @U0CKQ19AQ and @U0522TWDA. @U0CKQ19AQ — I have exactly this remote which serves up the access token. The issue is that I need to call the async JS function to make sure that the token is refreshed. Otherwise, it is simple for me to implement the solution you outlined.

hadils16:09:35

Perhaps I can refresh the token with a state machine…

tony.kay16:09:54

yeah, this is all outside of the scope of Fulcro proper...asynchrony in general is meant to mostly go in remotes...but you're free to do whatever you ahve to do for js interop. In this case the auth token IS global state. There is only one...I would just stuff it in an atom and run a goloop or something to keep it fresh, and use the atom directly in the middleware of the remote.

tony.kay16:09:44

I don't know the API you're using, so hard to say exactly.

hadils16:09:51

That’s a great idea @U0CKQ19AQ!

hadils15:09:05

Should i just surround. the body of the transmit! function with. a go block?

lance.paine16:09:00

In my toy learning project, I've got a model with a list of FIBO legal entities. Each entity has some details, like a legalName, and links to other entities, like a headQuarters address, and a legalAddress (both of which are BusinessRegistrationAddresses) I'm running resolver queries against a SPARQL triple store. Questions) 1) Legal Entities have two types of Addresses (legal and hq), and address has a country. What steps do I need to take in both resolvers, and components, to allow that to traverse? Do I make some sort of attribute alias, so that legal-entity/legAddr and legal-entity/hqAddr can both be mapped to business-address/id ? At the moment, I can get something like this:

{:legal-entity/all-legal-entities
 [{:legal-entity/hqAddr
   "",
   :legal-entity/legAddr
   "",
   :legal-entity/legalName "Company 1 Ltd",
   :legal-entity/id
   ""}
  {:legal-entity/hqAddr
   "",
   :legal-entity/legAddr
   "",
   :legal-entity/legalName "Company Company Ltd",
   :legal-entity/id
   ""}
At the moment, I'm loading the address data on demand as a button in a legal entity for the address is clicked. But I'd like to make, say, the Country visible next to the legalName. To make those addresses traversable, do I need to make them idents in the resolver? Like:
{:legal-entity/hqAddr
   [:address/id ""]}
I've tried adding a resolver:
(defresolver legAddr->business-registration-id-resolver [env id]
  ;; "treat the legal-entity/legAddr as an address/id"
  {::pc/input #{:legal-entity/legAddr}
   ::pc/output [:business-registration-address/id :business-registration-address/city :business-registration-address/country]}
  (let [id (:legal-entity/legAddr id)
        results (sparql-queries/get-legal-entity-addresses env {"$id" (u/str->sparqliri id)})]
    (log/info "legAddr -> business id " id results)
    (first results)))
And then various queries like
[{:legal-entity/all-legal-entities
  [:legal-entity/id
   :legal-entity/legalName
   :legal-entity/hqAddr :legal-entity/legAddr {:legal-entity/legAddr [:business-registration-address/id :business-registration-address/city]}]}]
But not working, I AM seeing my resolver being hit. The closest I've got is with
[{:legal-entity/all-legal-entities
  [:legal-entity/id
   :legal-entity/legalName
   :legal-entity/hqAddr :business-registration-address/id]}]
returning the iri value of the legAddr in the :business-registration-address/id slot, and I've seen pathom triggering the recursive queries, and the queries are shown in the Graph in the 'Network' tab (very cool) and getting results, but I'm not seeing them stitched into the overall response.

lance.paine17:09:01

having thought I'd tried so many combos, I think I might've answered my own question! Making the resolver thus:

(defresolver legAddr->business-registration-id-resolver [env id]
  ;; "treat the legal-entity/legAddr as an address/id"
  {::pc/input #{:legal-entity/legAddr}
   ::pc/output [:business-registration-address/address]}
  (let [id (:legal-entity/legAddr id)
        results (sparql-queries/get-legal-entity-addresses env {"$id" (u/str->sparqliri id)})]
    (log/info "legAddr -> business id " id results)
    {:business-registration-address/address (first results)}))
then a query such as
[
   {:legal-entity/all-legal-entities
    [:legal-entity/id
     :legal-entity/legalName
     :legal-entity/hqAddr 
     :legal-entity/legAddr 
     {:business-registration-address/address
      [:business-registration-address/country 
       :business-registration-address/addressLine1]}]}]
       
     
does the recursive calls. so my problem was my resolver needed to return a map, with an attr keying the data?

tony.kay02:09:59

I hope you figured it out…this one was a bit too long for my available time 😄

lance.paine11:09:34

I figured out how to make it work, but not sure I truly understand why it worked. I'm finding I feel like I get various bits and then when I stitch them together my understanding wasn't as solid as I thought. Gonna buy some time from @U0522TWDA tomorrow to learn from his experience. I remain very impressed by all that I see and hopeful that once I truly grok it will prove fruitful for some projects I have in mind. I'm keeping some notes of "aha" moments and stumbling blocks so hopefully will be able to contribute those to help others. Thanks @U0CKQ19AQ

tony.kay12:09:36

The usual "aha" moment is that it's simpler than you're making it 🙂

2
😂 1
tony.kay12:09:59

but as with anything, practice is necessary for it to fall into place