Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$announcer instance not available with Vue 2 Composition API and TypeScript #27

Open
ux-engineer opened this issue Oct 18, 2021 · 3 comments

Comments

@ux-engineer
Copy link

While this plugin does not support TypeScript yet, those errors can be skipped with // @ts-ignore comments.

However, I'm having major difficulty using this plugin with Composition API for Vue 2. Can't upgrade to Vue 3 yet so next branch is not a solution here.

How can I access $announcer instance from the setup method?

@ktquez
Copy link
Member

ktquez commented Oct 19, 2021

@ux-engineer

It's not an ideal or definitive solution, but it can be temporary until we find a better alternative and add a new version of vue-announcer for Vue 2 with composition-api support.

https://codesandbox.io/s/ukxsq?file=/src/components/HelloWorld.vue

@ux-engineer
Copy link
Author

@ktquez thanks a lot, this helps!

An idea: Could it be possible to have the option of being able to pass a function as message or complementRoute, especially message, so i18n logics could easily be bound to the configuration?

If given a function as a value, you would invoke it and catch it's return value (string expected).

For example we could achieve reactive and translatable messages in route object meta config:

// import { t } from '@/i18n';

{
  name: 'home',
  path: '/',
  component: Home,
  meta: {
    announcer: {
      message: () => t('PAGE__HOME__TITLE')
    }
  }
}

@ktquez
Copy link
Member

ktquez commented Oct 20, 2021

I think it's possible!
My time is pretty short, but as soon as I have some free time I'll add it in a new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants