Fork me on GitHub

I have been trying to implement the following and so far not able to find a way: I have a list of items displayed on the page. An item can be active or inactive depending on its current state. Every active item has a "progress" which needs to be displayed on it as a percentage (this value is stored and constantly being updated on the server). Now, I need to implement a probing mechanism for repeatedly retrieving the latest progress numbers for all the active items (with say 10 second intervals), and the probing should only happen when the there's at least one active item.


The first question is: where should I put the timer code? Seems that I might want to put it at a hook that gets called every time the item states are changed. Is there such a hook?


The reason I would want to have the timer logic in a state monitoring hook rather than in the client init function is that I would want to not probe when there's no active items (which is the majority of the time).


There’s always the option of checking for active items in the actual timer firing event, and then avoiding the load! it there are none. Not sure how many items you’ll be working with tho. Fulcro does have react hooks support as well. Might be worth looking at.

👍 3

1 possible way to do it: You could create a recursive mutation, using set-timeout from js to get the 10s delay. When no active users are remaining flip a switch in the db and the mutation kills itself. (i.e. does not schedule itself again)

👍 3

@tony.kay where I assoc (assoc-in sui/all-controls [?report ?field :inst] (fn [app value] ...) ?? (to customize ALL field of type :inst in reports)


@souenzzo report fields can have styles. See semantic ui plugin’s code (just look at that all-controls definition)


ATM I'm using this ro/field-formatters {:app/date (fn [app value] (.toLocaleDateString value ...))}


I will search about SUI plugins


I found it interesting that the "state" in a UI State Machine is not really a complete snapshot of the local "model" (in an MVC sense.) Rather, it's almost just a helper for the UISM event routing to decide which handler gets called when such event is handled at multiple states. The meat of UISM seem to always be in the event handlers, in the form of side-effecting. I found UISMs in fulcro more like attachments closely snapped onto the UI code. They read values directly from the UI and generate side-effects directly on to the UI. The attachments themselves only have a loose (leaky) sense of "state", and writing them don't feel like writing a self-contained "model" or "state machine" at all as you probably need to know a lot about the specific UI itself.


But I guess it aligns with the recurring theme in Fulcro that the model knowing the UI has some benefits (e.g. the model knowing the shape of the UI query avoids needing to sync the model code and the UI code; the model knowing the names of the UI props means one doesn't have to manually map them; etc)


You are in a state, and yes, the rest of it is part of the intentional design


it actually works out quite well…RAD has a grand total of 2 UIMS machines that can control any standard form (nested) or report independent of UI


the point is to concentrate logic and add a little bit of FSM to it…there is a state that is tracked, which you are in, which determines where you are in (your) state diagram, and also then defines the edges (triggered by events)


but it is by no means an academic state machine system…it just borrows most of the practically useful stuff for this particular abstraction


That is also why it isn’t called FSM, or state charts…they are UI state machines…with full-stack in mind


Fulcro is pragmatic 1st, by design


I see. It makes much more sense now. No I'm not criticizing fulcro, just an effort to orient myself and develop an intuition for your design


yep, I didn’t take it as criticism 😄


To be honest certain namespaces, such as dynamic-routing and ui-state-machines, started out as pure experiments to see how the design of them would work. They were both in F2 incubator. I found them to be quite useful myself and promoted them to the library proper. That said, they are somewhat radical in their design in that they leverage things only Fulcro has (at least that was the case when written…some things may have since appeared in other places in other libs, or may have predated my “invention”).


well, for that matter, I guess most of the entire library is a series of experiments that have “mostly” gone right 😜