import Taro from "@tarojs/taro";

const KEY = 'VIDEO_EVENTS'

interface Data {
  id: number
  view: number
}

function videoAdd(data: Data) {
  Taro.eventCenter.trigger(KEY + data.id, data)
}

function videoOn(id: number, fn: (data: Data) => void) {
  Taro.eventCenter.on(KEY + id, fn)
}

function off(id: number) {
  Taro.eventCenter.off(KEY + id)
}

const VideoEvent = {
  videoAdd,
  videoOn,
  off
}

export default VideoEvent
