Fork me on GitHub
#fulcro
<
2021-03-27
>
Cristian Saucedo02:03:39

I have a situation where I have a relationship in one of my models in mr frontend fulcro db with a 1 to 1 relation ship with another model, something like

{:person/id 3
  ...
  person/pet [pet/id 5]}
The other model (`pet` in this case) does not contain this relationship because it seems redundant. If I have several of both of these types of records, what would be "right" way to derive the inverse relationship (being able to go from pet/id to person/id. I have a few questions about some possible solutions. • Is there a way to query this from the db? I know something like this would be possible in Datalog, but EQL documentation didn't mention anything simillar • Is there a way to create state derived from other state within fulcro? Something that would listen to the person/id map and derive a mapping from pet/id to person/id. I've done this before in re-frame, though their implementation is not super performant • Am I completely off base and I should just add the person/id relationship to the pet model. Even if #3 is the way to go, if there are ways to do #1 or #2 it would be great to know.

Timofey Sitnikov12:03:03

Good Morning all, If I do this:

(ns app.myns
  (:require
    [com.fulcrologic.fulcro.dom :as dom]
    [clojure.pprint :refer [pprint]]))

(pprint (div :.ur.blah))
I get this:
#js {"$$typeof" #object[Symbol(react.element)], :type "div", :key nil, :ref nil, :props #js {:className "ur blah"}, :_owner nil, :_store #js {}}
How does Fulcro turn declared div into a function?

donavan14:03:33

It’ll help you to watch these videos to understand what dom/div is doing https://www.youtube.com/playlist?list=PLVi9lDx-4C_TBRiHfjnjXaK2J3BIUDPnf

Timofey Sitnikov18:03:50

@U0VP19K6K, the mystery I am trying to solve is how the dev declaration converts to a function in the source. Its in this namespace: https://github.com/fulcrologic/fulcro/blob/develop/src/main/com/fulcrologic/fulcro/dom.cljs

donavan18:03:40

There is both a macro div and function div . Is that what you’re talking about?

Timofey Sitnikov18:03:42

Possibly, but in the source, you simply (dev :.ui.main), where is the div declared as a function or macro looking at the fulcro.dom source. Sorry, I am pretty new to Clojure and trying to figure out how things work.

Timofey Sitnikov19:03:24

This is probably more of just Clojure question.

donavan19:03:34

right, i think what’s confusing you is it’s generated in a macro

donavan19:03:53

If you’re not so sure about what a macro is then, yes, it’s a clojure question 🙂

donavan19:03:32

I would watch the videos I posted above… as far as I remember Tony touched on this stuff

Timofey Sitnikov19:03:35

OK, so basically all of the declared values in dom.cljs are converted to functions using the macros. Therefore, all of these functions will have the same arguments.

donavan19:03:52

Yeah, they all behave very similarly

donavan19:03:04

The macros create the functions at compile time

donavan19:03:45

…well the one macro creates the macro versions and the other macro creates the function versions

Timofey Sitnikov19:03:53

Actually, I am not far enough into it to understand the videos. I am working up to it. Trying to understand some basic things. Also, I tend to learn much better after I dig into coded and understand it.

donavan19:03:47

Yeah, I wouldn’t worry about all this macro stuff… just use them, there’s a lot to learn before worrying about how the dom macros/functions are created

donavan19:03:14

Any way, good luck. I’m off for supper

Timofey Sitnikov19:03:19

Yeh, I am beginning to see how Tony layers the macros. Thats crazy, he is super smart.

Timofey Sitnikov19:03:32

Thank you and enjoy supper.

Aleksander Rendtslev22:03:59
replied to a thread:

How about the many to many scenario? Post <--many--> Topic In my particular case all of the content is individually genenrated. So instead of running queries against a remote, I gathered that it makes more sense to sync all the data to the client. The next question is whether I should dump all of it into Fulcro or create a local remote using Datascript, Datahike or Asami and then run my queries against that. The downside seems to be, as the user navigates through the app, the database would start living in both `local db` and `fulcro` (unless I clean up fulcro as you use the app)