Fork me on GitHub
#fulcro
<
2022-09-02
>
genekim05:09:58

@tony.kay My apologies for what will seem like a random question — I’ll ask the question first, and then some background. In RAD, where is the state set that causes controls to get disabled during while it is waiting for data to be loaded? E.g., when running a report, the button controls such as Refresh will not be enabled until after the filter, sort, populate page, etc. The reason: I had written a UI State Machine that is similar to your incremental loader. But it used mutations to load the next pages, so that it would always filter/sort/paginate, and render the data that has been loaded. It was a bit of a hack. But I loved it, because the report would show whatever data was loaded, I could use the keyboard to switch between pages, all while I was doing df/load to load more data/rows, which would often take 30+ seconds. I’m trying to add this functionality to your incremental report loading, using your interface to resolvers (which is awesome, by the way). But currently, nothing gets rendered until all the data is loaded. In my attempts to try enabling the controls, I’ve changed your process-loaded-page adding the following to env: https://github.com/fulcrologic/fulcro-rad/blob/develop/src/main/com/fulcrologic/rad/state_machines/incrementally_loaded_report.cljc#L92

(-> env
      (uism/apply-action append-results)
      (cond->
        more? (uism/load source-attribute nil (merge
                                                {:params            current-params
                                                 ::uism/ok-event    :event/page-loaded
                                                 ::uism/error-event :event/failed
                                                 :marker            report-ident
                                                 :target            page-path}
                                                load-options))
        (not more?) (uism/trigger report-ident :event/loaded))
      ; GK: added this to render first frame earlier, but controls are disabled until all data is loaded...
      (report/preprocess-raw-result)
      (report/filter-rows)
      (report/sort-rows)
      (report/populate-current-page)
      (cond-> report-loaded report-loaded))
But controls are only enabled for a fraction of a second upon load completion, before they’re disabled again (for another 3-4 seconds). Is there a way to leave this function with the controls enabled? (Even if that means that re-pagination may do strange things to the current view.) Maybe my mental model of how this UISM is wrong — but where in that state machine are controls being disabled? Thank you!

👀 1
genekim20:09:41

I wanted to share how I solved this problem of getting Fulcro RAD reports to render the first frame before the resolver returns all of the data. Often, this is 30+ seconds, which I was dissatisfied with. I modified the Fulcro RAD “incrementally-loaded-report” UISM. However, instead of rendering only after the resolver returns the entire data set, it renders immediately after the first small load completes (enough to render a couple of pages), and use df/load! to asynchronously load each chunk. I use df/load! because it’s asynchronous, versus uism/load which doesn’t allow mutations or changing the query-params while loading. Personal note: I’m finding UISM to be a marvel. It’s amazing that you can pull out all the I/O stuff into UISMs, and I’m amazed that I could change the I/O behavior so easily. It’s likely less than 20 LoC difference than the original. Thanks @tony.kay for creating UISM, and @holyjak for your fantastic “minimalist tutorials”, which helped me finish this. You can find the source code here in this gist: https://gist.github.com/realgenekim/32188389abc670a16bcd715e41245c62

🙏 1
genekim20:09:07

(When I have a little time, I’ll post an animated GIF of the before vs. after, switching out this UISM for the incrementally-loaded-report UISM. 🙂

sheluchin20:09:26

Thanks for posting, @U6VPZS1EK! I haven't gone down this path just yet but I think your gist will be handy for reference when I do.

Jakub Holý (HolyJak)21:09:30

Thanks for sharing, and your kind words!

genekim20:09:41
replied to a thread:@tony.kay My apologies for what will seem like a random question — I’ll ask the question first, and then some background. In RAD, where is the state set that causes controls to get disabled during while it is waiting for data to be loaded? E.g., when running a report, the button controls such as Refresh will not be enabled until after the filter, sort, populate page, etc. The reason: I had written a UI State Machine that is similar to your incremental loader. But it used mutations to load the next pages, so that it would always filter/sort/paginate, and render the data that has been loaded. It was a bit of a hack. But I loved it, because the report would show whatever data was loaded, I could use the keyboard to switch between pages, all while I was doing `df/load` to load more data/rows, which would often take 30+ seconds. I’m trying to add this functionality to your incremental report loading, using your interface to resolvers (which is awesome, by the way). But currently, nothing gets rendered until all the data is loaded. In my attempts to try enabling the controls, I’ve changed your `process-loaded-page` adding the following to env: https://github.com/fulcrologic/fulcro-rad/blob/develop/src/main/com/fulcrologic/rad/state_machines/incrementally_loaded_report.cljc#L92 (-&gt; env (uism/apply-action append-results) (cond-&gt; more? (uism/load source-attribute nil (merge {:params current-params ::uism/ok-event :event/page-loaded ::uism/error-event :event/failed :marker report-ident :target page-path} load-options)) (not more?) (uism/trigger report-ident :event/loaded)) ; GK: added this to render first frame earlier, but controls are disabled until all data is loaded... (report/preprocess-raw-result) (report/filter-rows) (report/sort-rows) (report/populate-current-page) (cond-&gt; report-loaded report-loaded)) But controls are only enabled for a fraction of a second upon load completion, before they’re disabled again (for another 3-4 seconds). Is there a way to leave this function with the controls enabled? (Even if that means that re-pagination may do strange things to the current view.) Maybe my mental model of how this UISM is wrong — but where in that state machine are controls being disabled? Thank you!

I wanted to share how I solved this problem of getting Fulcro RAD reports to render the first frame before the resolver returns all of the data. Often, this is 30+ seconds, which I was dissatisfied with. I modified the Fulcro RAD “incrementally-loaded-report” UISM. However, instead of rendering only after the resolver returns the entire data set, it renders immediately after the first small load completes (enough to render a couple of pages), and use df/load! to asynchronously load each chunk. I use df/load! because it’s asynchronous, versus uism/load which doesn’t allow mutations or changing the query-params while loading. Personal note: I’m finding UISM to be a marvel. It’s amazing that you can pull out all the I/O stuff into UISMs, and I’m amazed that I could change the I/O behavior so easily. It’s likely less than 20 LoC difference than the original. Thanks @tony.kay for creating UISM, and @holyjak for your fantastic “minimalist tutorials”, which helped me finish this. You can find the source code here in this gist: https://gist.github.com/realgenekim/32188389abc670a16bcd715e41245c62

🙏 1