'use strict'

import { get } from 'bwindow'

export const RESIZE_EVENT = 'ap:header:resize'

export function addResizeHandler (handler) {
  const window = get('window')
  window.addEventListener(RESIZE_EVENT, handler)
}

export function removeResizeHandler (handler) {
  const window = get('window')
  window.removeEventListener(RESIZE_EVENT, handler)
}

export function triggerResize () {
  const window = get('window')
  const Event = get('Event')
  let event = new Event(RESIZE_EVENT)
  window.dispatchEvent(event)
}

export default {
  RESIZE_EVENT,
  addResizeHandler,
  removeResizeHandler,
  triggerResize
}
