import { common } from '@kit.AbilityKit';
import { RewardAd } from '../../ads/RewardAd';
import { emitter } from '@kit.BasicServicesKit';


@Component
export struct ShowJHRewardAd {
  @BuilderParam showAdStruct: () => void
  private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;

  aboutToAppear(): void {
    emitter.on('showJHAd', () => {
      new RewardAd(this.context)
    })
  }

  aboutToDisappear(): void {
    emitter.off('showJHAd')
  }

  build() {
    this.showAdStruct()
  }
}