Component Name: pageRefresher¶
Last Updated: 2025-09-29 Source Code: https://bitbucket.org/i2cinc/i2c.salesforce.metadata/src/STAGING/force-app/main/default/lwc/pageRefresher
API Name: c-pageRefresher Type: Service Component Target: Not exposed
Business Purpose¶
Listens for Platform Events (Page_Refresher__e) and automatically refreshes the current record page when the event is received. This enables real-time updates when backend processes modify records, ensuring users always see current data without manual refresh.
User Interface¶
No visible UI - service component only
Component Structure¶
Files¶
pageRefresher.html- Empty templatepageRefresher.js- Controller (30 lines)pageRefresher.js-meta.xml- Not exposed
JavaScript Controller¶
Properties (API)¶
@api recordId¶
- Type:
String - Description: Record ID to monitor/refresh
Wire Adapters¶
@wire(getRecord, { recordId: '$recordId'})¶
- Loads record data
- Stores result for refreshApex
Lifecycle¶
connectedCallback()¶
- Subscribes to
/event/Page_Refresher__eplatform event channel - Replay ID: -1 (all new events)
- On event received:
- Dispatches RefreshEvent()
- Calls refreshApex(this.record)
- Logs subscription confirmation
disconnectedCallback()¶
- Unsubscribes from platform event channel
- Logs unsubscribe confirmation
Dependencies¶
Lightning Platform¶
lightning/empApi: Platform event subscriptionlightning/refresh: RefreshEvent APIlightning/uiRecordApi: getRecord wire@salesforce/apex: refreshApex
Platform Events¶
Page_Refresher__e: Custom platform event
Usage Examples¶
Backend Trigger¶
// Publish event to trigger refresh
Page_Refresher__e event = new Page_Refresher__e();
EventBus.publish(event);
⚠️ Pre-Go-Live Concerns¶
CRITICAL¶
- No record filtering: All pages refresh when ANY Page_Refresher__e event fires - should include record ID in event
HIGH¶
- No unit tests: Zero coverage
- Console.log in production: Lines 20, 27
- No error handling: onError from empApi not used
- Subscription never stored: May cause memory leak
MEDIUM¶
- Refresh entire page: RefreshEvent() refreshes all components, not just this record
- No visual feedback: User doesn't know refresh happened
Maintenance Notes¶
Complexity: Low Key Notes: - CRITICAL: Currently refreshes ALL pages listening to event, needs record-specific filtering - Uses Salesforce Platform Event (Streaming API) - Replay ID -1 gets only new events (not historical) - Component must be on page to receive events - Consider adding record ID to platform event payload for targeted refresh
Browser Compatibility: - Requires modern browser with Streaming API support