fulcro

Eric Dvorsak 2025-07-25T10:05:42.955469Z

Is this a bug in fulcro statecharts?

(transition {:cond (fn [_ data event-name event-data]
                     (println :cond :event-name event-name :event-data event-data))}
            (script-fn [_ data event-name event-data]
                       (println :script :event-name event-name :event-data event-data)))


=> :cond nil nil
=> :script ok ok
I would have expected the event and event-data to also be available within the cond?

Eric Dvorsak 2025-07-29T09:37:14.421699Z

(state {:id :state/closed}
                    (transition {:cond (fn [_ data])
                                 :target [:state/lti-mode :state/lti-choosing-step]})
                    (transition {:event :event/open-modal
                                 :cond (fn [_ _ _ event-data])
                                 :target [:state/lti-mode :state/lti-choosing-step]})
                    (transition {:event :event/open-modal
                                 :target [:state/regular-mode :state/name-step]}))
yeah I have to study this deeper, the first transition cond is actually only evaluated when the statechart starts and not anymore when the :event/open-modal is received so my solution now is to have a transition that explicitely has that event defined, even though it's a dev onyl thing because the first transition :cond is checking the url for params

Eric Dvorsak 2025-07-25T11:19:23.757549Z

so when this behavior only occurs when there is no event key

michaelwhitford 2025-07-25T16:23:02.678319Z

IIRC on the cond it's available in :_event of data.

michaelwhitford 2025-07-25T16:24:15.131859Z

I don't have a test cond to tap from but you can put a tap into your cond there and see if data has :_event with that info.

Eric Dvorsak 2025-07-25T16:25:32.204319Z

No it's not, at least not when there is no :event in the transition

michaelwhitford 2025-07-25T16:26:36.753229Z

Ahh yeah that makes sense, misunderstood what you meant there. If there is no event then :_event won't be populated, since that only gets added from the event.

tony.kay 2025-07-25T22:20:26.650839Z

It could be a bug. The fact that the transition isn’t event-based (it is a default) is still going to happen in some context where some kind of event occurred (unless it is startup)…so on the surface I would expect the “current contextual event” to perhaps be available. I’m not sure if the W3C spec has anything to say about this case, but I also don’t really see the harm in it. Statecharts (and machines in general) can have additional things “happen”…e.g. a transition that is taken that causes another transition, etc. The whole thing eventually stabilizes. So, in the cases of the processing these “secondary” transitions there may be something in the spec that says the event isn’t there because an event didn’t cause it, but I don’t remember any such specification. It is probably just an oversight.

tony.kay 2025-07-25T22:21:34.571199Z

If you can find the section of the SCXML spec that covers this stuff, you could clarify how it MUST work, at which point we can determine if this is a bug. You could also look at the impl file and just try to put the event in context. I don’t see any reason for it to not be there unless it is startup and there was no event.

Josh Wood 2025-07-25T16:33:51.455119Z

I'm struggling with GraphQL integration in my Fulcro3/Pathom2 app and am in need of some advice. I'm querying against Github's API and have run into a road block with gql->eql syntax. Here is the gql query I'm trying to implement:

{
 repository(owner: "owner", name: "name") {
  object(expression: "main:") {
   ... on Tree {
    id
    entries {
     oid
     path
     type
     name
    }
   }
  }
 }
}
;; Here is my current ident-map
::pcg/ident-map 
{"repository" {"owner" :github.repository/owner
               "name"  :github.repository/name}
 "object"     {"expression" :github.object/expression}}
Dynamic indexing is working fine for 'repository' and 'object' and I'm able to return data, but I'm stuck on the '... on Tree' line. I'm not sure how to properly translate this. Anybody have any ideas? Thanks in advance!