Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

Commit

Permalink
fix(rtdb): fix global vue 2
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Dec 1, 2020
1 parent c529d88 commit 8dcf8ef
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/vuefire/rtdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
toRef,
getCurrentInstance,
onBeforeUnmount,
isVue3,
} from 'vue-demi'

/**
Expand Down Expand Up @@ -171,7 +172,11 @@ export const rtdbPlugin = function rtdbPlugin(
const globalOptions = Object.assign({}, defaultOptions, pluginOptions)
const { bindName, unbindName } = globalOptions

app.config.globalProperties[unbindName] = function rtdbUnbind(
const GlobalTarget = isVue3
? app.config.globalProperties
: (app as any).prototype

GlobalTarget[unbindName] = function rtdbUnbind(
key: string,
reset?: RTDBOptions['reset']
) {
Expand All @@ -180,7 +185,7 @@ export const rtdbPlugin = function rtdbPlugin(
}

// add $rtdbBind and $rtdbUnbind methods
app.config.globalProperties[bindName] = function rtdbBind(
GlobalTarget[bindName] = function rtdbBind(
this: ComponentPublicInstance,
key: string,
source: database.Reference | database.Query,
Expand Down

0 comments on commit 8dcf8ef

Please sign in to comment.