import { ref } from 'vue'

const announcement = ref('')

export function useAnnouncer() {
  function announce(message: string) {
    // Clear then set to ensure repeated identical messages are announced
    announcement.value = ''
    requestAnimationFrame(() => {
      announcement.value = message
    })
  }

  return { announcement, announce }
}
