How to use the @vue/composition-api.inject function in @vue/composition-api

To help you get started, we’ve selected a few @vue/composition-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vuejs / vue-test-utils / test / resources / components / component-with-inject-composition.vue View on Github external
setup: () => {
    const fromMount = inject('fromMount')
    const setInSetup = ref('created')

    return {
      fromMount,
      setInSetup
    }
  }
})
github LinusBorg / composition-api-demos / src / store / index.js View on Github external
export const useNotifications = () => inject(key)
github vuejs / vue-apollo / packages / vue-apollo-composable / src / useApolloClient.ts View on Github external
export function useApolloClient (clientId: string = null) {
  const providedApolloClients: { [key: string]: ApolloClient } = inject(ApolloClients, null)
  const providedApolloClient: ApolloClient = inject(DefaultApolloClient, null)

  function resolveClient (clientId: string = null): ApolloClient {
    let resolvedClient
    if (clientId) {
      if (!providedApolloClients) {
        throw new Error(`No apolloClients injection found, tried to resolve '${clientId}' clientId`)
      }
      resolvedClient = providedApolloClients[clientId]
    } else {
      clientId = 'default'
      if (providedApolloClients) {
        resolvedClient = providedApolloClients.default
      } else {
        resolvedClient = providedApolloClient
      }
    }
github PECE-project / drupal-pece / src / front / components / ui / FormLabel.vue View on Github external
setup () {
    const required = inject('required')

    return {
      required
    }
  }
}
github PatrykWalach / vuex-composition-api / src / install.ts View on Github external
export const useStore = () => inject(key) as Hook
github vuejs / vue-apollo / packages / vue-apollo-composable / src / useApolloClient.ts View on Github external
export function useApolloClient (clientId: string = null) {
  const providedApolloClients: { [key: string]: ApolloClient } = inject(ApolloClients, null)
  const providedApolloClient: ApolloClient = inject(DefaultApolloClient, null)

  function resolveClient (clientId: string = null): ApolloClient {
    let resolvedClient
    if (clientId) {
      if (!providedApolloClients) {
        throw new Error(`No apolloClients injection found, tried to resolve '${clientId}' clientId`)
      }
      resolvedClient = providedApolloClients[clientId]
    } else {
      clientId = 'default'
      if (providedApolloClients) {
        resolvedClient = providedApolloClients.default
      } else {
        resolvedClient = providedApolloClient
      }