This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-22
Channels
- # announcements (88)
- # autochrome-github (2)
- # babashka (26)
- # beginners (5)
- # biff (2)
- # cider (73)
- # clj-kondo (4)
- # cljsrn (6)
- # clojure (54)
- # clojure-art (3)
- # clojure-europe (73)
- # clojure-germany (5)
- # clojure-new-zealand (1)
- # clojure-nl (13)
- # clojure-norway (16)
- # clojure-uk (8)
- # clojurescript (73)
- # conjure (1)
- # core-async (10)
- # cursive (17)
- # datahike (51)
- # datalevin (21)
- # datomic (4)
- # emacs (2)
- # events (3)
- # fulcro (35)
- # honeysql (6)
- # introduce-yourself (1)
- # jackdaw (3)
- # jobs (1)
- # leiningen (4)
- # lsp (3)
- # malli (17)
- # off-topic (60)
- # other-languages (5)
- # pathom (17)
- # pedestal (3)
- # polylith (19)
- # portal (2)
- # practicalli (1)
- # rdf (14)
- # reitit (3)
- # releases (1)
- # reveal (9)
- # sci (1)
- # shadow-cljs (26)
- # spacemacs (17)
- # sql (4)
- # testing (10)
- # tools-build (6)
- # tools-deps (16)
- # vim (9)
Can I run transact!
without a component? e.g. in the then
callback of a promise
ya - you can pass a fulcro app - and if you want you can set the :ref
option on the transaction, this is what transact!
does when you pass a component instance: https://github.com/fulcrologic/fulcro/blob/a5f5b2121ca97739bf986412bf3c081c3a078b33/src/main/com/fulcrologic/fulcro/raw/components.cljc#L409
perfect thank you!
Hi, how can I update ui according to a statemachine state? (something like :query
for statemachines)?
This is a very general question. The main thing to remember is that the UI is a function of the Fulcro client DB (`view = fn(data)`). The short answer is that you update your UI by updating the database using mutations (`transact!`) and loads (`merge!`, load!
).
If you haven't already, I recommend checking out https://fulcro-community.github.io/guides/tutorial-minimalist-fulcro/
thank you, I actually found my answer here, I was looking for uism/asm-ident
Is there a way to access component props in the :query
attribute?
Because I need to retrieve the uism/asm-ident
corresponding to that component ident.
{:query (fn [] [:connect/id :connect/name
(uism/asm-ident [:connect/id id])])}
but I guess this is circular reasoning, right?
(from the docs: https://book.fulcrologic.com/#_looking_at_the_running_instance)
I think you should be identifying your asm by keyword there. The ASM id won't be the same as the current component id, I don't think..
It is, I initialize it with:
(uism/begin! this providers/connect
[:connect/id id]
{:actor/connect-button this})
the id is [:connect/id id]
Am I not allowed to do that? If not, how do I make parametrized state machines?
(uism/begin! app-or-component machine-def instance-id actor-map)
Installs an instance of a state machine (to be known as instance-id, an arbitrary keyword), based on the definition in machine-def, into Fulcro’s state and sends the ::uism/started event.
oh yeah, a keyword
that's very limiting, though
I think what you want is to add an actor to that state machine and have that actor correspond to your component, rather than coupling your SM to your UI at the top level.
Yes, but I have multiple instances of the same component that each need to access their own SM instance
should I open a feature request?
I think you should try to describe what you're trying to do in a bit more detail and see if someone with a bit more experience can help you out.
okay, thank you.
You can have multiple instances of a component, each with its own instance of the SM, the component instance being an actor in the uism.
There's something I'm missing from the fulcro picture. How does a component query data outside of its local :initial-state
?
It may be better to explain more of what you’re trying to achieve but you could possibly use ident joins. I’m not sure if there is a section in the docs for it but if you search for ident join
Some info on link queries which are a kind of special case ident join https://book.fulcrologic.com/#_link_queries
I think this is the section in the docs that talk about them https://book.fulcrologic.com/#_idents_as_a_query_element
Thank you, I'll look for that
BTW initial state is only one source of data. Merge or df/load is another. To access data not belonging to the data entity, use Ident or Link queries - see https://blog.jakubholy.net/2020/fulcro-divergent-ui-data/ But make sure you understand Fulcro well and are not trying to force an incorrect solution to a need. As suggested elsewhere, the minimalist tutorial and its exercises should help.
@U0111PVCS8P What I think is important for you to understand is, that the queries of components are not run against a database on their own. It is not like your components query for data and get "their own data" delivered straight from the database. Instead, queries are composed together and in the end there is only one query run against one (normalized) database. This query is located in your "Root Component". In the end, your root component gets a single tree of data, that it feeds down your render functions.
This, for example, doesn't work:
(def db
{:foo "bar"})
(defsc B [{:keys [foo]} _]
{:query [:foo]}
(dom/p "foo"))
(def ui-b (comp/factory B))
(defsc Root [_ _]
{:query []}
(ui-b))
B
doesn't "pull" :foo
from the db by itself.
The query of the root component is used to shape the normalized database into a denormalized tree.
This tree is fed to the render function of the root component.
And because the query of the root node is []
, the data fed to the root is empty {}
.See the diagram https://fulcro-community.github.io/guides/tutorial-minimalist-fulcro/#_components_query for a visual of the above explanation.