Nuxt.js: Inject plugin in $root state & context

Created on 1 Sep 2017  路  3Comments  路  Source: nuxt/nuxt.js

I was try to write and inject horizon.io plugin in the $root (app) with documented way:

export default ({ app, store }) => {
  app.$horizon = horizon
}

but something was wrong and the injected props will append into $store key:

image

As you can see, $horizon will added into $store -> $store.$horizon, and into $store.app -> $store.app.$horizon.

If I test like firebase example, the result will be the same:
image

This question is available on Nuxt.js community (#c1386)
documentation

Most helpful comment

export default (context, inject) => {
  inject('horizon', horizon)
}

will create $horizon, the documentation need to be completed (WIP).

All 3 comments

export default (context, inject) => {
  inject('horizon', horizon)
}

will create $horizon, the documentation need to be completed (WIP).

@alexchopin Hello !
Thanks for the info.

Did you close the issue because it has been documented properly ?

At the moment https://nuxtjs.org/guide/plugins is not reflecting your comment.
There is an example of the usage of inject, but the inject function itself is not documented like you state here (key,value) will be available as $key

Let me know if you want me to open another issue to improve the documentation.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mattdharmon picture mattdharmon  路  3Comments

pehbehbeh picture pehbehbeh  路  3Comments

msudgh picture msudgh  路  3Comments

vadimsg picture vadimsg  路  3Comments

nassimbenkirane picture nassimbenkirane  路  3Comments