mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
feat(subscription): invalidate subscription cache
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import events from '@/subscribers/events';
|
||||
import Container from 'typedi';
|
||||
|
||||
export class TriggerInvalidateCacheOnSubscriptionChange {
|
||||
/**
|
||||
* Attaches events with handlers.
|
||||
*/
|
||||
public attach = (bus) => {
|
||||
bus.subscribe(
|
||||
events.subscription.onSubscriptionCancelled,
|
||||
this.triggerInvalidateCache.bind(this)
|
||||
);
|
||||
bus.subscribe(
|
||||
events.subscription.onSubscriptionResumed,
|
||||
this.triggerInvalidateCache.bind(this)
|
||||
);
|
||||
bus.subscribe(
|
||||
events.subscription.onSubscriptionPlanChanged,
|
||||
this.triggerInvalidateCache.bind(this)
|
||||
);
|
||||
};
|
||||
|
||||
private triggerInvalidateCache() {
|
||||
const io = Container.get('socket');
|
||||
|
||||
// Notify the frontend to reflect the new transactions changes.
|
||||
io.emit('SUBSCRIPTION_CHANGED', { subscriptionSlug: 'main' });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user