I’m writing a small library that deals with reacting to databroadcast events.
The basic premise Listen for events on Table A, run methods for Table B".
Works very well as long as the databroadcast events originate from outside the client running the library.
However in a situation where the setup is more complicated, e.g.
On Table A event, update Table B
On Table B event, update Table C
The client is not receiving messages about Table B events after reacting to Table A events. I assume this is because they originated locally.
Considering this scenario, I have two questions
- Is the observed behavior correct, or should I be receiving databroadcasts for all events regardless of origination.
- If this is the correct behavior, what would be the optimal solution for working around this behavior?
Currently ‘Table B’ is being updated by a FoundSetUpdater. I’ve found that I can force a databroadcast event by calling ‘plugins.rawSQL.notifyDataChange’. This ‘works’ but I have concerns over the performance impact of two notifications being sent. The performance of the client running my library (runs server side) is of less concern than the performance of the other clients that might be receiving double notifications.
That being said, should I continue with using both the FoundSetUpdater and a forced notify, or, to avoid double notifications, should I be updating my records using rawSQL and then forcing the notify?
Or something else entirely?
databroadcast are never send to the origination (because that one doesn’t need it because it already has the changes)
its sounds a bit like a calculation (on table b) to me (but then you have to have some (global) relation between them that the calc uses)
It does sound that way, doesn’t it? For the sake of this discussion though, let’s pretend that I’m over-simplifying the situation, and that what is being triggered is more complex than what a calculation represents.
That being the case, any comments between the two update methodologies?
FoundSetUpdater & notify
vs
rawSQL & notify
That’s largely the same (depending a bit on which method of the foundset updater is used) Because the foundset updater can do also 1 update query to update a lot (and then it does already do a flush that will flush all the clients so no need for a extra notify then)
But i guess you really only use the notify of the rawsql because that call really does also notify itself…
So you could also just do record.mycolumn = 10; databaseManager.saveData(record); notifyDataChange(forthatrecordid)
then clients would get 2x a data notify, one by self itself and the other by your code.
What does the action behind that double notification look like?
Will that cause clients that have the effected record in cache to do retrieve updated data twice? If it will update twice, is that happening on the user thread (so will potentially block and/or client would notice) or is it happening transparently in the background?
for updates yes all the clients will get for that row the latest data when they receive a update broadcast for it