Reputation: 878
I have a scenario where I'll be doing many updates that end up effecting a Result that my VC is listening to. Ideally I'd just send 1 notification at the end of my batch
A few questions:
Upvotes: 1
Views: 326
Reputation: 15991
Notifications only occur at the end of a write transaction, so the easiest thing to do for this case would be to perform all of your work in one transaction (I'd definitely recommend doing it on a background thread), and then close it when you want the notification to be fired.
This would be the general recommended approach since it would guarantee all fine-grained change indexes are coalesced into that singular notification at the end.
If you don't care about the fine-grained change indexes (i.e., you're just doing a complete refresh on each notification), then you definitely could consider simply setting a flag that disregards notifications until you've completed your work.
You could also remove the notification block, but this would mean there'd be a significant amount of tear-down, and re-setup work you'd have to do each time.
Upvotes: 3