import { Events, events } from '@blocklet/sdk/lib/config';

import logger from '../../libs/logger';
import { initPaywallResources } from '../../libs/resource';

const handlePaywallResources = () => {
  logger.info('handlePaywallResources on blocklet change');
  setTimeout(initPaywallResources, 1000);
};

export function initResourceHandler() {
  events.on(Events.componentAdded, handlePaywallResources);
  events.on(Events.componentStarted, handlePaywallResources);
  events.on(Events.envUpdate, handlePaywallResources);
}
