I have a lwc that works with Event Platforms, but event limits are exceeded and I can't reduce them. Is there any functionality or method that can refresh my component in real time without platform events?.
1 Answer
Sometimes money is an answer, consider buying an addon to increase the limit.
If it's 1 component talking to another component on same page and telling it to rerender - look into Lightning Message Service. It's not perfect (couldn't get it to work on mobile) but could be good enough for you.
When all else fails - consider handmade polling. What if you use window.setTimeout() and call apex function say every 5 seconds to check if stuff changed. It'll be network-intensive but could be good enough to fetch fresh data.
2 Comments
Arturo Castro
Thanks for the answer, I also thought of querying the database from lwc; but Im not sure if there are a limit of queries per day on Sforce?, because I'll call my method every X seconds by Y numbers of users.
eyescream
it doesn't count as API access, you should be fine. If the operation is expensive and rarely changes you could consider using Platform Cache. 1 user runs the query, you realise stuff changed, write result to cache + timestamp maybe, next user comes and checks cache first? if it's from last X seconds - grabs the value as is without calculation fresh