Refreshable global methods with local scope #4301
Replies: 2 comments
-
Hi, @mbrulatout! If that so, you might want consider an approach mentioned in #4321 . Hope it helped! |
Beta Was this translation helpful? Give feedback.
-
Hi @mbrulatout, not sure if it suits your use case but you might want to take a look at StatefulRefreshable here: #4172 (comment) My approach is to always pass a state var to a refreshable and have the 'client' (eg, page function) link it up to app.storage.* for sharing (or not sharing) state and for persistence. |
Beta Was this translation helpful? Give feedback.
-
Question
Hi there,
We hit an issue with module level refreshables, which ended up sharing context between users. After digging a bit, we found that this was documented.
Based on the variant C doc, I expected the following MRE to work.
Spoiler: while
time
works,time2
refresh doesn't.Somehow, I guess that you can't "bind the
refreshable
property to an existing object"While
time2
doesn't make much sense here as it's a MRE, in quite complex scenarii, where a global method defining various elements that need to be refreshed in multiple other methods, it does.You could think about this simple usecase:
table.refresh()
in each impacting code path.Due to the ever-growing amount of nested methods callbacks, passing
ui.refreshable
args everywhere offers a bad DX overall.I ended up writing something like the following. It's basically a refreshable storage, hiding some of the complexity to allow usecases like
time2
to work this time. I had to use some client storage to avoid shared context again.While this works fine, and seems to answer my needs, it doesn't look that great.
Would you happen to have any recommendation about that kind of usecases ?
Beta Was this translation helpful? Give feedback.
All reactions