@vueuse/firebase 6.3.2 → 6.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs CHANGED
@@ -5,91 +5,78 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var vueDemi = require('vue-demi');
6
6
  var shared = require('@vueuse/shared');
7
7
 
8
- function useAuth(authInstance) {
9
- let auth;
10
- if (authInstance instanceof Function)
11
- auth = authInstance();
12
- else
13
- auth = authInstance;
14
- const user = vueDemi.ref(auth.currentUser);
15
- const isAuthenticated = vueDemi.computed(() => !!user.value);
16
- auth.onIdTokenChanged(authUser => user.value = authUser);
17
- return {
18
- isAuthenticated,
19
- user,
20
- };
8
+ function useAuth(authInstance) {
9
+ let auth;
10
+ if (authInstance instanceof Function)
11
+ auth = authInstance();
12
+ else
13
+ auth = authInstance;
14
+ const user = vueDemi.ref(auth.currentUser);
15
+ const isAuthenticated = vueDemi.computed(() => !!user.value);
16
+ auth.onIdTokenChanged((authUser) => user.value = authUser);
17
+ return {
18
+ isAuthenticated,
19
+ user
20
+ };
21
21
  }
22
22
 
23
- function getData(docRef) {
24
- const data = docRef.data();
25
- if (data) {
26
- Object.defineProperty(data, 'id', {
27
- value: docRef.id.toString(),
28
- writable: false,
29
- });
30
- }
31
- return data;
32
- }
33
- function isDocumentReference(docRef) {
34
- var _a;
35
- return (((_a = docRef.path) === null || _a === void 0 ? void 0 : _a.match(/\//g)) || []).length % 2 !== 0;
36
- }
37
- /**
38
- * Reactive Firestore binding. Making it straightforward to always keep your
39
- * local data in sync with remotes databases.
40
- *
41
- * @see https://vueuse.org/useFirestore
42
- * @param docRef
43
- * @param initialValue
44
- * @param options
45
- */
46
- function useFirestore(docRef, initialValue = undefined, options = {}) {
47
- const {
48
- // eslint-disable-next-line no-console
49
- errorHandler = (err) => console.error(err), autoDispose = true, } = options;
50
- if (isDocumentReference(docRef)) {
51
- const data = vueDemi.ref(initialValue);
52
- const close = docRef.onSnapshot((snapshot) => {
53
- data.value = getData(snapshot) || null;
54
- }, errorHandler);
55
- shared.tryOnScopeDispose(() => {
56
- close();
57
- });
58
- return data;
59
- }
60
- else {
61
- const data = vueDemi.ref(initialValue);
62
- const close = docRef.onSnapshot((snapshot) => {
63
- data.value = snapshot.docs.map(getData).filter(shared.isDef);
64
- }, errorHandler);
65
- if (autoDispose) {
66
- shared.tryOnScopeDispose(() => {
67
- close();
68
- });
69
- }
70
- return data;
71
- }
23
+ function getData(docRef) {
24
+ const data = docRef.data();
25
+ if (data) {
26
+ Object.defineProperty(data, "id", {
27
+ value: docRef.id.toString(),
28
+ writable: false
29
+ });
30
+ }
31
+ return data;
32
+ }
33
+ function isDocumentReference(docRef) {
34
+ var _a;
35
+ return (((_a = docRef.path) == null ? void 0 : _a.match(/\//g)) || []).length % 2 !== 0;
36
+ }
37
+ function useFirestore(docRef, initialValue = void 0, options = {}) {
38
+ const {
39
+ errorHandler = (err) => console.error(err),
40
+ autoDispose = true
41
+ } = options;
42
+ if (isDocumentReference(docRef)) {
43
+ const data = vueDemi.ref(initialValue);
44
+ const close = docRef.onSnapshot((snapshot) => {
45
+ data.value = getData(snapshot) || null;
46
+ }, errorHandler);
47
+ shared.tryOnScopeDispose(() => {
48
+ close();
49
+ });
50
+ return data;
51
+ } else {
52
+ const data = vueDemi.ref(initialValue);
53
+ const close = docRef.onSnapshot((snapshot) => {
54
+ data.value = snapshot.docs.map(getData).filter(shared.isDef);
55
+ }, errorHandler);
56
+ if (autoDispose) {
57
+ shared.tryOnScopeDispose(() => {
58
+ close();
59
+ });
60
+ }
61
+ return data;
62
+ }
72
63
  }
73
64
 
74
- /**
75
- * Reactive Firebase Realtime Database binding.
76
- *
77
- * @param docRef
78
- * @param options
79
- */
80
- function useRTDB(docRef, options = {}) {
81
- const { autoDispose = true, } = options;
82
- const data = vueDemi.ref(undefined);
83
- function update(snapshot) {
84
- data.value = snapshot.val();
85
- }
86
- docRef.on('value', update);
87
- if (autoDispose) {
88
- shared.tryOnScopeDispose(() => {
89
- docRef.off('value', update);
90
- });
91
- }
92
- return data;
65
+ function useRTDB(docRef, options = {}) {
66
+ const {
67
+ autoDispose = true
68
+ } = options;
69
+ const data = vueDemi.ref(void 0);
70
+ function update(snapshot) {
71
+ data.value = snapshot.val();
72
+ }
73
+ docRef.on("value", update);
74
+ if (autoDispose) {
75
+ shared.tryOnScopeDispose(() => {
76
+ docRef.off("value", update);
77
+ });
78
+ }
79
+ return data;
93
80
  }
94
81
 
95
82
  exports.useAuth = useAuth;
package/index.iife.js CHANGED
@@ -62,91 +62,78 @@
62
62
  ;(function (exports, vueDemi, shared) {
63
63
  'use strict';
64
64
 
65
- function useAuth(authInstance) {
66
- let auth;
67
- if (authInstance instanceof Function)
68
- auth = authInstance();
69
- else
70
- auth = authInstance;
71
- const user = vueDemi.ref(auth.currentUser);
72
- const isAuthenticated = vueDemi.computed(() => !!user.value);
73
- auth.onIdTokenChanged(authUser => user.value = authUser);
74
- return {
75
- isAuthenticated,
76
- user,
77
- };
65
+ function useAuth(authInstance) {
66
+ let auth;
67
+ if (authInstance instanceof Function)
68
+ auth = authInstance();
69
+ else
70
+ auth = authInstance;
71
+ const user = vueDemi.ref(auth.currentUser);
72
+ const isAuthenticated = vueDemi.computed(() => !!user.value);
73
+ auth.onIdTokenChanged((authUser) => user.value = authUser);
74
+ return {
75
+ isAuthenticated,
76
+ user
77
+ };
78
78
  }
79
79
 
80
- function getData(docRef) {
81
- const data = docRef.data();
82
- if (data) {
83
- Object.defineProperty(data, 'id', {
84
- value: docRef.id.toString(),
85
- writable: false,
86
- });
87
- }
88
- return data;
89
- }
90
- function isDocumentReference(docRef) {
91
- var _a;
92
- return (((_a = docRef.path) === null || _a === void 0 ? void 0 : _a.match(/\//g)) || []).length % 2 !== 0;
93
- }
94
- /**
95
- * Reactive Firestore binding. Making it straightforward to always keep your
96
- * local data in sync with remotes databases.
97
- *
98
- * @see https://vueuse.org/useFirestore
99
- * @param docRef
100
- * @param initialValue
101
- * @param options
102
- */
103
- function useFirestore(docRef, initialValue = undefined, options = {}) {
104
- const {
105
- // eslint-disable-next-line no-console
106
- errorHandler = (err) => console.error(err), autoDispose = true, } = options;
107
- if (isDocumentReference(docRef)) {
108
- const data = vueDemi.ref(initialValue);
109
- const close = docRef.onSnapshot((snapshot) => {
110
- data.value = getData(snapshot) || null;
111
- }, errorHandler);
112
- shared.tryOnScopeDispose(() => {
113
- close();
114
- });
115
- return data;
116
- }
117
- else {
118
- const data = vueDemi.ref(initialValue);
119
- const close = docRef.onSnapshot((snapshot) => {
120
- data.value = snapshot.docs.map(getData).filter(shared.isDef);
121
- }, errorHandler);
122
- if (autoDispose) {
123
- shared.tryOnScopeDispose(() => {
124
- close();
125
- });
126
- }
127
- return data;
128
- }
80
+ function getData(docRef) {
81
+ const data = docRef.data();
82
+ if (data) {
83
+ Object.defineProperty(data, "id", {
84
+ value: docRef.id.toString(),
85
+ writable: false
86
+ });
87
+ }
88
+ return data;
89
+ }
90
+ function isDocumentReference(docRef) {
91
+ var _a;
92
+ return (((_a = docRef.path) == null ? void 0 : _a.match(/\//g)) || []).length % 2 !== 0;
93
+ }
94
+ function useFirestore(docRef, initialValue = void 0, options = {}) {
95
+ const {
96
+ errorHandler = (err) => console.error(err),
97
+ autoDispose = true
98
+ } = options;
99
+ if (isDocumentReference(docRef)) {
100
+ const data = vueDemi.ref(initialValue);
101
+ const close = docRef.onSnapshot((snapshot) => {
102
+ data.value = getData(snapshot) || null;
103
+ }, errorHandler);
104
+ shared.tryOnScopeDispose(() => {
105
+ close();
106
+ });
107
+ return data;
108
+ } else {
109
+ const data = vueDemi.ref(initialValue);
110
+ const close = docRef.onSnapshot((snapshot) => {
111
+ data.value = snapshot.docs.map(getData).filter(shared.isDef);
112
+ }, errorHandler);
113
+ if (autoDispose) {
114
+ shared.tryOnScopeDispose(() => {
115
+ close();
116
+ });
117
+ }
118
+ return data;
119
+ }
129
120
  }
130
121
 
131
- /**
132
- * Reactive Firebase Realtime Database binding.
133
- *
134
- * @param docRef
135
- * @param options
136
- */
137
- function useRTDB(docRef, options = {}) {
138
- const { autoDispose = true, } = options;
139
- const data = vueDemi.ref(undefined);
140
- function update(snapshot) {
141
- data.value = snapshot.val();
142
- }
143
- docRef.on('value', update);
144
- if (autoDispose) {
145
- shared.tryOnScopeDispose(() => {
146
- docRef.off('value', update);
147
- });
148
- }
149
- return data;
122
+ function useRTDB(docRef, options = {}) {
123
+ const {
124
+ autoDispose = true
125
+ } = options;
126
+ const data = vueDemi.ref(void 0);
127
+ function update(snapshot) {
128
+ data.value = snapshot.val();
129
+ }
130
+ docRef.on("value", update);
131
+ if (autoDispose) {
132
+ shared.tryOnScopeDispose(() => {
133
+ docRef.off("value", update);
134
+ });
135
+ }
136
+ return data;
150
137
  }
151
138
 
152
139
  exports.useAuth = useAuth;
@@ -155,4 +142,4 @@
155
142
 
156
143
  Object.defineProperty(exports, '__esModule', { value: true });
157
144
 
158
- }(this.VueUse = this.VueUse || {}, VueDemi, VueUse));
145
+ })(this.VueUse = this.VueUse || {}, VueDemi, VueUse);
package/index.iife.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){if(!e.VueDemi){var o={},n=e.Vue;if(n)if("2."===n.version.slice(0,2)){var i=e.VueCompositionAPI;if(i){for(var r in i)o[r]=i[r];o.isVue2=!0,o.isVue3=!1,o.install=function(){},o.Vue=n,o.Vue2=n,o.version=n.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.")}else if("3."===n.version.slice(0,2)){for(var r in n)o[r]=n[r];o.isVue2=!1,o.isVue3=!0,o.install=function(){},o.Vue=n,o.Vue2=void 0,o.version=n.version,o.set=function(e,o,n){return Array.isArray(e)?(e.length=Math.max(e.length,o),e.splice(o,1,n),n):(e[o]=n,n)},o.del=function(e,o){Array.isArray(e)?e.splice(o,1):delete e[o]}}else console.error("[vue-demi] Vue version "+n.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");e.VueDemi=o}}(window),function(e,o,n){"use strict";function i(e){const o=e.data();return o&&Object.defineProperty(o,"id",{value:e.id.toString(),writable:!1}),o}e.useAuth=function(e){let n;n=e instanceof Function?e():e;const i=o.ref(n.currentUser),r=o.computed((()=>!!i.value));return n.onIdTokenChanged((e=>i.value=e)),{isAuthenticated:r,user:i}},e.useFirestore=function(e,r,s={}){const{errorHandler:t=(e=>console.error(e)),autoDispose:u=!0}=s;if(function(e){var o;return((null===(o=e.path)||void 0===o?void 0:o.match(/\//g))||[]).length%2!=0}(e)){const s=o.ref(r),u=e.onSnapshot((e=>{s.value=i(e)||null}),t);return n.tryOnScopeDispose((()=>{u()})),s}{const s=o.ref(r),a=e.onSnapshot((e=>{s.value=e.docs.map(i).filter(n.isDef)}),t);return u&&n.tryOnScopeDispose((()=>{a()})),s}},e.useRTDB=function(e,i={}){const{autoDispose:r=!0}=i,s=o.ref(void 0);function t(e){s.value=e.val()}return e.on("value",t),r&&n.tryOnScopeDispose((()=>{e.off("value",t)})),s},Object.defineProperty(e,"__esModule",{value:!0})}(this.VueUse=this.VueUse||{},VueDemi,VueUse);
1
+ (function(s){if(!s.VueDemi){var e={},n=s.Vue;if(n)if(n.version.slice(0,2)==="2."){var d=s.VueCompositionAPI;if(d){for(var t in d)e[t]=d[t];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=n,e.Vue2=n,e.version=n.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.")}else if(n.version.slice(0,2)==="3."){for(var t in n)e[t]=n[t];e.isVue2=!1,e.isVue3=!0,e.install=function(){},e.Vue=n,e.Vue2=void 0,e.version=n.version,e.set=function(u,c,a){return Array.isArray(u)?(u.length=Math.max(u.length,c),u.splice(c,1,a),a):(u[c]=a,a)},e.del=function(u,c){if(Array.isArray(u)){u.splice(c,1);return}delete u[c]}}else console.error("[vue-demi] Vue version "+n.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");s.VueDemi=e}})(window),function(s,e,n){"use strict";function d(r){let o;r instanceof Function?o=r():o=r;const l=e.ref(o.currentUser),f=e.computed(()=>!!l.value);return o.onIdTokenChanged(v=>l.value=v),{isAuthenticated:f,user:l}}function t(r){const o=r.data();return o&&Object.defineProperty(o,"id",{value:r.id.toString(),writable:!1}),o}function u(r){var o;return(((o=r.path)==null?void 0:o.match(/\//g))||[]).length%2!=0}function c(r,o=void 0,l={}){const{errorHandler:f=i=>console.error(i),autoDispose:v=!0}=l;if(u(r)){const i=e.ref(o),p=r.onSnapshot(V=>{i.value=t(V)||null},f);return n.tryOnScopeDispose(()=>{p()}),i}else{const i=e.ref(o),p=r.onSnapshot(V=>{i.value=V.docs.map(t).filter(n.isDef)},f);return v&&n.tryOnScopeDispose(()=>{p()}),i}}function a(r,o={}){const{autoDispose:l=!0}=o,f=e.ref(void 0);function v(i){f.value=i.val()}return r.on("value",v),l&&n.tryOnScopeDispose(()=>{r.off("value",v)}),f}s.useAuth=d,s.useFirestore=c,s.useRTDB=a,Object.defineProperty(s,"__esModule",{value:!0})}(this.VueUse=this.VueUse||{},VueDemi,VueUse);
package/index.mjs CHANGED
@@ -1,91 +1,78 @@
1
1
  import { ref, computed } from 'vue-demi';
2
2
  import { tryOnScopeDispose, isDef } from '@vueuse/shared';
3
3
 
4
- function useAuth(authInstance) {
5
- let auth;
6
- if (authInstance instanceof Function)
7
- auth = authInstance();
8
- else
9
- auth = authInstance;
10
- const user = ref(auth.currentUser);
11
- const isAuthenticated = computed(() => !!user.value);
12
- auth.onIdTokenChanged(authUser => user.value = authUser);
13
- return {
14
- isAuthenticated,
15
- user,
16
- };
4
+ function useAuth(authInstance) {
5
+ let auth;
6
+ if (authInstance instanceof Function)
7
+ auth = authInstance();
8
+ else
9
+ auth = authInstance;
10
+ const user = ref(auth.currentUser);
11
+ const isAuthenticated = computed(() => !!user.value);
12
+ auth.onIdTokenChanged((authUser) => user.value = authUser);
13
+ return {
14
+ isAuthenticated,
15
+ user
16
+ };
17
17
  }
18
18
 
19
- function getData(docRef) {
20
- const data = docRef.data();
21
- if (data) {
22
- Object.defineProperty(data, 'id', {
23
- value: docRef.id.toString(),
24
- writable: false,
25
- });
26
- }
27
- return data;
28
- }
29
- function isDocumentReference(docRef) {
30
- var _a;
31
- return (((_a = docRef.path) === null || _a === void 0 ? void 0 : _a.match(/\//g)) || []).length % 2 !== 0;
32
- }
33
- /**
34
- * Reactive Firestore binding. Making it straightforward to always keep your
35
- * local data in sync with remotes databases.
36
- *
37
- * @see https://vueuse.org/useFirestore
38
- * @param docRef
39
- * @param initialValue
40
- * @param options
41
- */
42
- function useFirestore(docRef, initialValue = undefined, options = {}) {
43
- const {
44
- // eslint-disable-next-line no-console
45
- errorHandler = (err) => console.error(err), autoDispose = true, } = options;
46
- if (isDocumentReference(docRef)) {
47
- const data = ref(initialValue);
48
- const close = docRef.onSnapshot((snapshot) => {
49
- data.value = getData(snapshot) || null;
50
- }, errorHandler);
51
- tryOnScopeDispose(() => {
52
- close();
53
- });
54
- return data;
55
- }
56
- else {
57
- const data = ref(initialValue);
58
- const close = docRef.onSnapshot((snapshot) => {
59
- data.value = snapshot.docs.map(getData).filter(isDef);
60
- }, errorHandler);
61
- if (autoDispose) {
62
- tryOnScopeDispose(() => {
63
- close();
64
- });
65
- }
66
- return data;
67
- }
19
+ function getData(docRef) {
20
+ const data = docRef.data();
21
+ if (data) {
22
+ Object.defineProperty(data, "id", {
23
+ value: docRef.id.toString(),
24
+ writable: false
25
+ });
26
+ }
27
+ return data;
28
+ }
29
+ function isDocumentReference(docRef) {
30
+ var _a;
31
+ return (((_a = docRef.path) == null ? void 0 : _a.match(/\//g)) || []).length % 2 !== 0;
32
+ }
33
+ function useFirestore(docRef, initialValue = void 0, options = {}) {
34
+ const {
35
+ errorHandler = (err) => console.error(err),
36
+ autoDispose = true
37
+ } = options;
38
+ if (isDocumentReference(docRef)) {
39
+ const data = ref(initialValue);
40
+ const close = docRef.onSnapshot((snapshot) => {
41
+ data.value = getData(snapshot) || null;
42
+ }, errorHandler);
43
+ tryOnScopeDispose(() => {
44
+ close();
45
+ });
46
+ return data;
47
+ } else {
48
+ const data = ref(initialValue);
49
+ const close = docRef.onSnapshot((snapshot) => {
50
+ data.value = snapshot.docs.map(getData).filter(isDef);
51
+ }, errorHandler);
52
+ if (autoDispose) {
53
+ tryOnScopeDispose(() => {
54
+ close();
55
+ });
56
+ }
57
+ return data;
58
+ }
68
59
  }
69
60
 
70
- /**
71
- * Reactive Firebase Realtime Database binding.
72
- *
73
- * @param docRef
74
- * @param options
75
- */
76
- function useRTDB(docRef, options = {}) {
77
- const { autoDispose = true, } = options;
78
- const data = ref(undefined);
79
- function update(snapshot) {
80
- data.value = snapshot.val();
81
- }
82
- docRef.on('value', update);
83
- if (autoDispose) {
84
- tryOnScopeDispose(() => {
85
- docRef.off('value', update);
86
- });
87
- }
88
- return data;
61
+ function useRTDB(docRef, options = {}) {
62
+ const {
63
+ autoDispose = true
64
+ } = options;
65
+ const data = ref(void 0);
66
+ function update(snapshot) {
67
+ data.value = snapshot.val();
68
+ }
69
+ docRef.on("value", update);
70
+ if (autoDispose) {
71
+ tryOnScopeDispose(() => {
72
+ docRef.off("value", update);
73
+ });
74
+ }
75
+ return data;
89
76
  }
90
77
 
91
78
  export { useAuth, useFirestore, useRTDB };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vueuse/firebase",
3
- "version": "6.3.2",
3
+ "version": "6.5.3",
4
4
  "description": "Enables realtime bindings for Firebase",
5
5
  "keywords": [
6
6
  "vue",
@@ -15,7 +15,7 @@
15
15
  "url": "git+https://github.com/vueuse/vueuse.git"
16
16
  },
17
17
  "funding": "https://github.com/sponsors/antfu",
18
- "author": "Anthony Fu<https://github.com/antfu>",
18
+ "author": "Anthony Fu <https://github.com/antfu>",
19
19
  "exports": {
20
20
  ".": {
21
21
  "import": "./index.mjs",
@@ -49,7 +49,7 @@
49
49
  "firebase": ">=4.0.0"
50
50
  },
51
51
  "dependencies": {
52
- "@vueuse/shared": "6.3.2",
52
+ "@vueuse/shared": "6.5.3",
53
53
  "vue-demi": "*"
54
54
  }
55
55
  }
package/useAuth.cjs CHANGED
@@ -4,19 +4,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var vueDemi = require('vue-demi');
6
6
 
7
- function useAuth(authInstance) {
8
- let auth;
9
- if (authInstance instanceof Function)
10
- auth = authInstance();
11
- else
12
- auth = authInstance;
13
- const user = vueDemi.ref(auth.currentUser);
14
- const isAuthenticated = vueDemi.computed(() => !!user.value);
15
- auth.onIdTokenChanged(authUser => user.value = authUser);
16
- return {
17
- isAuthenticated,
18
- user,
19
- };
7
+ function useAuth(authInstance) {
8
+ let auth;
9
+ if (authInstance instanceof Function)
10
+ auth = authInstance();
11
+ else
12
+ auth = authInstance;
13
+ const user = vueDemi.ref(auth.currentUser);
14
+ const isAuthenticated = vueDemi.computed(() => !!user.value);
15
+ auth.onIdTokenChanged((authUser) => user.value = authUser);
16
+ return {
17
+ isAuthenticated,
18
+ user
19
+ };
20
20
  }
21
21
 
22
22
  exports.useAuth = useAuth;
package/useAuth.iife.js CHANGED
@@ -62,23 +62,23 @@
62
62
  ;(function (exports, vueDemi) {
63
63
  'use strict';
64
64
 
65
- function useAuth(authInstance) {
66
- let auth;
67
- if (authInstance instanceof Function)
68
- auth = authInstance();
69
- else
70
- auth = authInstance;
71
- const user = vueDemi.ref(auth.currentUser);
72
- const isAuthenticated = vueDemi.computed(() => !!user.value);
73
- auth.onIdTokenChanged(authUser => user.value = authUser);
74
- return {
75
- isAuthenticated,
76
- user,
77
- };
65
+ function useAuth(authInstance) {
66
+ let auth;
67
+ if (authInstance instanceof Function)
68
+ auth = authInstance();
69
+ else
70
+ auth = authInstance;
71
+ const user = vueDemi.ref(auth.currentUser);
72
+ const isAuthenticated = vueDemi.computed(() => !!user.value);
73
+ auth.onIdTokenChanged((authUser) => user.value = authUser);
74
+ return {
75
+ isAuthenticated,
76
+ user
77
+ };
78
78
  }
79
79
 
80
80
  exports.useAuth = useAuth;
81
81
 
82
82
  Object.defineProperty(exports, '__esModule', { value: true });
83
83
 
84
- }(this.VueUse = this.VueUse || {}, VueDemi));
84
+ })(this.VueUse = this.VueUse || {}, VueDemi);
@@ -1 +1 @@
1
- !function(e){if(!e.VueDemi){var i={},n=e.Vue;if(n)if("2."===n.version.slice(0,2)){var o=e.VueCompositionAPI;if(o){for(var s in o)i[s]=o[s];i.isVue2=!0,i.isVue3=!1,i.install=function(){},i.Vue=n,i.Vue2=n,i.version=n.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.")}else if("3."===n.version.slice(0,2)){for(var s in n)i[s]=n[s];i.isVue2=!1,i.isVue3=!0,i.install=function(){},i.Vue=n,i.Vue2=void 0,i.version=n.version,i.set=function(e,i,n){return Array.isArray(e)?(e.length=Math.max(e.length,i),e.splice(i,1,n),n):(e[i]=n,n)},i.del=function(e,i){Array.isArray(e)?e.splice(i,1):delete e[i]}}else console.error("[vue-demi] Vue version "+n.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");e.VueDemi=i}}(window),function(e,i){"use strict";e.useAuth=function(e){let n;n=e instanceof Function?e():e;const o=i.ref(n.currentUser),s=i.computed((()=>!!o.value));return n.onIdTokenChanged((e=>o.value=e)),{isAuthenticated:s,user:o}},Object.defineProperty(e,"__esModule",{value:!0})}(this.VueUse=this.VueUse||{},VueDemi);
1
+ (function(s){if(!s.VueDemi){var e={},i=s.Vue;if(i)if(i.version.slice(0,2)==="2."){var o=s.VueCompositionAPI;if(o){for(var n in o)e[n]=o[n];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=i,e.Vue2=i,e.version=i.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.")}else if(i.version.slice(0,2)==="3."){for(var n in i)e[n]=i[n];e.isVue2=!1,e.isVue3=!0,e.install=function(){},e.Vue=i,e.Vue2=void 0,e.version=i.version,e.set=function(u,r,t){return Array.isArray(u)?(u.length=Math.max(u.length,r),u.splice(r,1,t),t):(u[r]=t,t)},e.del=function(u,r){if(Array.isArray(u)){u.splice(r,1);return}delete u[r]}}else console.error("[vue-demi] Vue version "+i.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");s.VueDemi=e}})(window),function(s,e){"use strict";function i(o){let n;o instanceof Function?n=o():n=o;const u=e.ref(n.currentUser),r=e.computed(()=>!!u.value);return n.onIdTokenChanged(t=>u.value=t),{isAuthenticated:r,user:u}}s.useAuth=i,Object.defineProperty(s,"__esModule",{value:!0})}(this.VueUse=this.VueUse||{},VueDemi);
package/useAuth.mjs CHANGED
@@ -1,18 +1,18 @@
1
1
  import { ref, computed } from 'vue-demi';
2
2
 
3
- function useAuth(authInstance) {
4
- let auth;
5
- if (authInstance instanceof Function)
6
- auth = authInstance();
7
- else
8
- auth = authInstance;
9
- const user = ref(auth.currentUser);
10
- const isAuthenticated = computed(() => !!user.value);
11
- auth.onIdTokenChanged(authUser => user.value = authUser);
12
- return {
13
- isAuthenticated,
14
- user,
15
- };
3
+ function useAuth(authInstance) {
4
+ let auth;
5
+ if (authInstance instanceof Function)
6
+ auth = authInstance();
7
+ else
8
+ auth = authInstance;
9
+ const user = ref(auth.currentUser);
10
+ const isAuthenticated = computed(() => !!user.value);
11
+ auth.onIdTokenChanged((authUser) => user.value = authUser);
12
+ return {
13
+ isAuthenticated,
14
+ user
15
+ };
16
16
  }
17
17
 
18
18
  export { useAuth };
package/useFirestore.cjs CHANGED
@@ -5,55 +5,46 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var vueDemi = require('vue-demi');
6
6
  var shared = require('@vueuse/shared');
7
7
 
8
- function getData(docRef) {
9
- const data = docRef.data();
10
- if (data) {
11
- Object.defineProperty(data, 'id', {
12
- value: docRef.id.toString(),
13
- writable: false,
14
- });
15
- }
16
- return data;
17
- }
18
- function isDocumentReference(docRef) {
19
- var _a;
20
- return (((_a = docRef.path) === null || _a === void 0 ? void 0 : _a.match(/\//g)) || []).length % 2 !== 0;
21
- }
22
- /**
23
- * Reactive Firestore binding. Making it straightforward to always keep your
24
- * local data in sync with remotes databases.
25
- *
26
- * @see https://vueuse.org/useFirestore
27
- * @param docRef
28
- * @param initialValue
29
- * @param options
30
- */
31
- function useFirestore(docRef, initialValue = undefined, options = {}) {
32
- const {
33
- // eslint-disable-next-line no-console
34
- errorHandler = (err) => console.error(err), autoDispose = true, } = options;
35
- if (isDocumentReference(docRef)) {
36
- const data = vueDemi.ref(initialValue);
37
- const close = docRef.onSnapshot((snapshot) => {
38
- data.value = getData(snapshot) || null;
39
- }, errorHandler);
40
- shared.tryOnScopeDispose(() => {
41
- close();
42
- });
43
- return data;
44
- }
45
- else {
46
- const data = vueDemi.ref(initialValue);
47
- const close = docRef.onSnapshot((snapshot) => {
48
- data.value = snapshot.docs.map(getData).filter(shared.isDef);
49
- }, errorHandler);
50
- if (autoDispose) {
51
- shared.tryOnScopeDispose(() => {
52
- close();
53
- });
54
- }
55
- return data;
56
- }
8
+ function getData(docRef) {
9
+ const data = docRef.data();
10
+ if (data) {
11
+ Object.defineProperty(data, "id", {
12
+ value: docRef.id.toString(),
13
+ writable: false
14
+ });
15
+ }
16
+ return data;
17
+ }
18
+ function isDocumentReference(docRef) {
19
+ var _a;
20
+ return (((_a = docRef.path) == null ? void 0 : _a.match(/\//g)) || []).length % 2 !== 0;
21
+ }
22
+ function useFirestore(docRef, initialValue = void 0, options = {}) {
23
+ const {
24
+ errorHandler = (err) => console.error(err),
25
+ autoDispose = true
26
+ } = options;
27
+ if (isDocumentReference(docRef)) {
28
+ const data = vueDemi.ref(initialValue);
29
+ const close = docRef.onSnapshot((snapshot) => {
30
+ data.value = getData(snapshot) || null;
31
+ }, errorHandler);
32
+ shared.tryOnScopeDispose(() => {
33
+ close();
34
+ });
35
+ return data;
36
+ } else {
37
+ const data = vueDemi.ref(initialValue);
38
+ const close = docRef.onSnapshot((snapshot) => {
39
+ data.value = snapshot.docs.map(getData).filter(shared.isDef);
40
+ }, errorHandler);
41
+ if (autoDispose) {
42
+ shared.tryOnScopeDispose(() => {
43
+ close();
44
+ });
45
+ }
46
+ return data;
47
+ }
57
48
  }
58
49
 
59
50
  exports.useFirestore = useFirestore;
@@ -62,59 +62,50 @@
62
62
  ;(function (exports, vueDemi, shared) {
63
63
  'use strict';
64
64
 
65
- function getData(docRef) {
66
- const data = docRef.data();
67
- if (data) {
68
- Object.defineProperty(data, 'id', {
69
- value: docRef.id.toString(),
70
- writable: false,
71
- });
72
- }
73
- return data;
74
- }
75
- function isDocumentReference(docRef) {
76
- var _a;
77
- return (((_a = docRef.path) === null || _a === void 0 ? void 0 : _a.match(/\//g)) || []).length % 2 !== 0;
78
- }
79
- /**
80
- * Reactive Firestore binding. Making it straightforward to always keep your
81
- * local data in sync with remotes databases.
82
- *
83
- * @see https://vueuse.org/useFirestore
84
- * @param docRef
85
- * @param initialValue
86
- * @param options
87
- */
88
- function useFirestore(docRef, initialValue = undefined, options = {}) {
89
- const {
90
- // eslint-disable-next-line no-console
91
- errorHandler = (err) => console.error(err), autoDispose = true, } = options;
92
- if (isDocumentReference(docRef)) {
93
- const data = vueDemi.ref(initialValue);
94
- const close = docRef.onSnapshot((snapshot) => {
95
- data.value = getData(snapshot) || null;
96
- }, errorHandler);
97
- shared.tryOnScopeDispose(() => {
98
- close();
99
- });
100
- return data;
101
- }
102
- else {
103
- const data = vueDemi.ref(initialValue);
104
- const close = docRef.onSnapshot((snapshot) => {
105
- data.value = snapshot.docs.map(getData).filter(shared.isDef);
106
- }, errorHandler);
107
- if (autoDispose) {
108
- shared.tryOnScopeDispose(() => {
109
- close();
110
- });
111
- }
112
- return data;
113
- }
65
+ function getData(docRef) {
66
+ const data = docRef.data();
67
+ if (data) {
68
+ Object.defineProperty(data, "id", {
69
+ value: docRef.id.toString(),
70
+ writable: false
71
+ });
72
+ }
73
+ return data;
74
+ }
75
+ function isDocumentReference(docRef) {
76
+ var _a;
77
+ return (((_a = docRef.path) == null ? void 0 : _a.match(/\//g)) || []).length % 2 !== 0;
78
+ }
79
+ function useFirestore(docRef, initialValue = void 0, options = {}) {
80
+ const {
81
+ errorHandler = (err) => console.error(err),
82
+ autoDispose = true
83
+ } = options;
84
+ if (isDocumentReference(docRef)) {
85
+ const data = vueDemi.ref(initialValue);
86
+ const close = docRef.onSnapshot((snapshot) => {
87
+ data.value = getData(snapshot) || null;
88
+ }, errorHandler);
89
+ shared.tryOnScopeDispose(() => {
90
+ close();
91
+ });
92
+ return data;
93
+ } else {
94
+ const data = vueDemi.ref(initialValue);
95
+ const close = docRef.onSnapshot((snapshot) => {
96
+ data.value = snapshot.docs.map(getData).filter(shared.isDef);
97
+ }, errorHandler);
98
+ if (autoDispose) {
99
+ shared.tryOnScopeDispose(() => {
100
+ close();
101
+ });
102
+ }
103
+ return data;
104
+ }
114
105
  }
115
106
 
116
107
  exports.useFirestore = useFirestore;
117
108
 
118
109
  Object.defineProperty(exports, '__esModule', { value: true });
119
110
 
120
- }(this.VueUse = this.VueUse || {}, VueDemi, VueUse));
111
+ })(this.VueUse = this.VueUse || {}, VueDemi, VueUse);
@@ -1 +1 @@
1
- !function(e){if(!e.VueDemi){var i={},o=e.Vue;if(o)if("2."===o.version.slice(0,2)){var n=e.VueCompositionAPI;if(n){for(var r in n)i[r]=n[r];i.isVue2=!0,i.isVue3=!1,i.install=function(){},i.Vue=o,i.Vue2=o,i.version=o.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.")}else if("3."===o.version.slice(0,2)){for(var r in o)i[r]=o[r];i.isVue2=!1,i.isVue3=!0,i.install=function(){},i.Vue=o,i.Vue2=void 0,i.version=o.version,i.set=function(e,i,o){return Array.isArray(e)?(e.length=Math.max(e.length,i),e.splice(i,1,o),o):(e[i]=o,o)},i.del=function(e,i){Array.isArray(e)?e.splice(i,1):delete e[i]}}else console.error("[vue-demi] Vue version "+o.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");e.VueDemi=i}}(window),function(e,i,o){"use strict";function n(e){const i=e.data();return i&&Object.defineProperty(i,"id",{value:e.id.toString(),writable:!1}),i}e.useFirestore=function(e,r,s={}){const{errorHandler:t=(e=>console.error(e)),autoDispose:u=!0}=s;if(function(e){var i;return((null===(i=e.path)||void 0===i?void 0:i.match(/\//g))||[]).length%2!=0}(e)){const s=i.ref(r),u=e.onSnapshot((e=>{s.value=n(e)||null}),t);return o.tryOnScopeDispose((()=>{u()})),s}{const s=i.ref(r),l=e.onSnapshot((e=>{s.value=e.docs.map(n).filter(o.isDef)}),t);return u&&o.tryOnScopeDispose((()=>{l()})),s}},Object.defineProperty(e,"__esModule",{value:!0})}(this.VueUse=this.VueUse||{},VueDemi,VueUse);
1
+ (function(o){if(!o.VueDemi){var e={},r=o.Vue;if(r)if(r.version.slice(0,2)==="2."){var l=o.VueCompositionAPI;if(l){for(var u in l)e[u]=l[u];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=r,e.Vue2=r,e.version=r.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.")}else if(r.version.slice(0,2)==="3."){for(var u in r)e[u]=r[u];e.isVue2=!1,e.isVue3=!0,e.install=function(){},e.Vue=r,e.Vue2=void 0,e.version=r.version,e.set=function(s,n,i){return Array.isArray(s)?(s.length=Math.max(s.length,n),s.splice(n,1,i),i):(s[n]=i,i)},e.del=function(s,n){if(Array.isArray(s)){s.splice(n,1);return}delete s[n]}}else console.error("[vue-demi] Vue version "+r.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");o.VueDemi=e}})(window),function(o,e,r){"use strict";function l(n){const i=n.data();return i&&Object.defineProperty(i,"id",{value:n.id.toString(),writable:!1}),i}function u(n){var i;return(((i=n.path)==null?void 0:i.match(/\//g))||[]).length%2!=0}function s(n,i=void 0,v={}){const{errorHandler:a=t=>console.error(t),autoDispose:p=!0}=v;if(u(n)){const t=e.ref(i),c=n.onSnapshot(f=>{t.value=l(f)||null},a);return r.tryOnScopeDispose(()=>{c()}),t}else{const t=e.ref(i),c=n.onSnapshot(f=>{t.value=f.docs.map(l).filter(r.isDef)},a);return p&&r.tryOnScopeDispose(()=>{c()}),t}}o.useFirestore=s,Object.defineProperty(o,"__esModule",{value:!0})}(this.VueUse=this.VueUse||{},VueDemi,VueUse);
package/useFirestore.mjs CHANGED
@@ -1,55 +1,46 @@
1
1
  import { ref } from 'vue-demi';
2
2
  import { tryOnScopeDispose, isDef } from '@vueuse/shared';
3
3
 
4
- function getData(docRef) {
5
- const data = docRef.data();
6
- if (data) {
7
- Object.defineProperty(data, 'id', {
8
- value: docRef.id.toString(),
9
- writable: false,
10
- });
11
- }
12
- return data;
13
- }
14
- function isDocumentReference(docRef) {
15
- var _a;
16
- return (((_a = docRef.path) === null || _a === void 0 ? void 0 : _a.match(/\//g)) || []).length % 2 !== 0;
17
- }
18
- /**
19
- * Reactive Firestore binding. Making it straightforward to always keep your
20
- * local data in sync with remotes databases.
21
- *
22
- * @see https://vueuse.org/useFirestore
23
- * @param docRef
24
- * @param initialValue
25
- * @param options
26
- */
27
- function useFirestore(docRef, initialValue = undefined, options = {}) {
28
- const {
29
- // eslint-disable-next-line no-console
30
- errorHandler = (err) => console.error(err), autoDispose = true, } = options;
31
- if (isDocumentReference(docRef)) {
32
- const data = ref(initialValue);
33
- const close = docRef.onSnapshot((snapshot) => {
34
- data.value = getData(snapshot) || null;
35
- }, errorHandler);
36
- tryOnScopeDispose(() => {
37
- close();
38
- });
39
- return data;
40
- }
41
- else {
42
- const data = ref(initialValue);
43
- const close = docRef.onSnapshot((snapshot) => {
44
- data.value = snapshot.docs.map(getData).filter(isDef);
45
- }, errorHandler);
46
- if (autoDispose) {
47
- tryOnScopeDispose(() => {
48
- close();
49
- });
50
- }
51
- return data;
52
- }
4
+ function getData(docRef) {
5
+ const data = docRef.data();
6
+ if (data) {
7
+ Object.defineProperty(data, "id", {
8
+ value: docRef.id.toString(),
9
+ writable: false
10
+ });
11
+ }
12
+ return data;
13
+ }
14
+ function isDocumentReference(docRef) {
15
+ var _a;
16
+ return (((_a = docRef.path) == null ? void 0 : _a.match(/\//g)) || []).length % 2 !== 0;
17
+ }
18
+ function useFirestore(docRef, initialValue = void 0, options = {}) {
19
+ const {
20
+ errorHandler = (err) => console.error(err),
21
+ autoDispose = true
22
+ } = options;
23
+ if (isDocumentReference(docRef)) {
24
+ const data = ref(initialValue);
25
+ const close = docRef.onSnapshot((snapshot) => {
26
+ data.value = getData(snapshot) || null;
27
+ }, errorHandler);
28
+ tryOnScopeDispose(() => {
29
+ close();
30
+ });
31
+ return data;
32
+ } else {
33
+ const data = ref(initialValue);
34
+ const close = docRef.onSnapshot((snapshot) => {
35
+ data.value = snapshot.docs.map(getData).filter(isDef);
36
+ }, errorHandler);
37
+ if (autoDispose) {
38
+ tryOnScopeDispose(() => {
39
+ close();
40
+ });
41
+ }
42
+ return data;
43
+ }
53
44
  }
54
45
 
55
46
  export { useFirestore };
package/useRTDB.cjs CHANGED
@@ -5,25 +5,21 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var vueDemi = require('vue-demi');
6
6
  var shared = require('@vueuse/shared');
7
7
 
8
- /**
9
- * Reactive Firebase Realtime Database binding.
10
- *
11
- * @param docRef
12
- * @param options
13
- */
14
- function useRTDB(docRef, options = {}) {
15
- const { autoDispose = true, } = options;
16
- const data = vueDemi.ref(undefined);
17
- function update(snapshot) {
18
- data.value = snapshot.val();
19
- }
20
- docRef.on('value', update);
21
- if (autoDispose) {
22
- shared.tryOnScopeDispose(() => {
23
- docRef.off('value', update);
24
- });
25
- }
26
- return data;
8
+ function useRTDB(docRef, options = {}) {
9
+ const {
10
+ autoDispose = true
11
+ } = options;
12
+ const data = vueDemi.ref(void 0);
13
+ function update(snapshot) {
14
+ data.value = snapshot.val();
15
+ }
16
+ docRef.on("value", update);
17
+ if (autoDispose) {
18
+ shared.tryOnScopeDispose(() => {
19
+ docRef.off("value", update);
20
+ });
21
+ }
22
+ return data;
27
23
  }
28
24
 
29
25
  exports.useRTDB = useRTDB;
package/useRTDB.iife.js CHANGED
@@ -62,29 +62,25 @@
62
62
  ;(function (exports, vueDemi, shared) {
63
63
  'use strict';
64
64
 
65
- /**
66
- * Reactive Firebase Realtime Database binding.
67
- *
68
- * @param docRef
69
- * @param options
70
- */
71
- function useRTDB(docRef, options = {}) {
72
- const { autoDispose = true, } = options;
73
- const data = vueDemi.ref(undefined);
74
- function update(snapshot) {
75
- data.value = snapshot.val();
76
- }
77
- docRef.on('value', update);
78
- if (autoDispose) {
79
- shared.tryOnScopeDispose(() => {
80
- docRef.off('value', update);
81
- });
82
- }
83
- return data;
65
+ function useRTDB(docRef, options = {}) {
66
+ const {
67
+ autoDispose = true
68
+ } = options;
69
+ const data = vueDemi.ref(void 0);
70
+ function update(snapshot) {
71
+ data.value = snapshot.val();
72
+ }
73
+ docRef.on("value", update);
74
+ if (autoDispose) {
75
+ shared.tryOnScopeDispose(() => {
76
+ docRef.off("value", update);
77
+ });
78
+ }
79
+ return data;
84
80
  }
85
81
 
86
82
  exports.useRTDB = useRTDB;
87
83
 
88
84
  Object.defineProperty(exports, '__esModule', { value: true });
89
85
 
90
- }(this.VueUse = this.VueUse || {}, VueDemi, VueUse));
86
+ })(this.VueUse = this.VueUse || {}, VueDemi, VueUse);
@@ -1 +1 @@
1
- !function(e){if(!e.VueDemi){var i={},o=e.Vue;if(o)if("2."===o.version.slice(0,2)){var s=e.VueCompositionAPI;if(s){for(var n in s)i[n]=s[n];i.isVue2=!0,i.isVue3=!1,i.install=function(){},i.Vue=o,i.Vue2=o,i.version=o.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.")}else if("3."===o.version.slice(0,2)){for(var n in o)i[n]=o[n];i.isVue2=!1,i.isVue3=!0,i.install=function(){},i.Vue=o,i.Vue2=void 0,i.version=o.version,i.set=function(e,i,o){return Array.isArray(e)?(e.length=Math.max(e.length,i),e.splice(i,1,o),o):(e[i]=o,o)},i.del=function(e,i){Array.isArray(e)?e.splice(i,1):delete e[i]}}else console.error("[vue-demi] Vue version "+o.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");e.VueDemi=i}}(window),function(e,i,o){"use strict";e.useRTDB=function(e,s={}){const{autoDispose:n=!0}=s,u=i.ref(void 0);function r(e){u.value=e.val()}return e.on("value",r),n&&o.tryOnScopeDispose((()=>{e.off("value",r)})),u},Object.defineProperty(e,"__esModule",{value:!0})}(this.VueUse=this.VueUse||{},VueDemi,VueUse);
1
+ (function(r){if(!r.VueDemi){var e={},i=r.Vue;if(i)if(i.version.slice(0,2)==="2."){var t=r.VueCompositionAPI;if(t){for(var s in t)e[s]=t[s];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=i,e.Vue2=i,e.version=i.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.")}else if(i.version.slice(0,2)==="3."){for(var s in i)e[s]=i[s];e.isVue2=!1,e.isVue3=!0,e.install=function(){},e.Vue=i,e.Vue2=void 0,e.version=i.version,e.set=function(u,n,o){return Array.isArray(u)?(u.length=Math.max(u.length,n),u.splice(n,1,o),o):(u[n]=o,o)},e.del=function(u,n){if(Array.isArray(u)){u.splice(n,1);return}delete u[n]}}else console.error("[vue-demi] Vue version "+i.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");r.VueDemi=e}})(window),function(r,e,i){"use strict";function t(s,u={}){const{autoDispose:n=!0}=u,o=e.ref(void 0);function f(l){o.value=l.val()}return s.on("value",f),n&&i.tryOnScopeDispose(()=>{s.off("value",f)}),o}r.useRTDB=t,Object.defineProperty(r,"__esModule",{value:!0})}(this.VueUse=this.VueUse||{},VueDemi,VueUse);
package/useRTDB.mjs CHANGED
@@ -1,25 +1,21 @@
1
1
  import { ref } from 'vue-demi';
2
2
  import { tryOnScopeDispose } from '@vueuse/shared';
3
3
 
4
- /**
5
- * Reactive Firebase Realtime Database binding.
6
- *
7
- * @param docRef
8
- * @param options
9
- */
10
- function useRTDB(docRef, options = {}) {
11
- const { autoDispose = true, } = options;
12
- const data = ref(undefined);
13
- function update(snapshot) {
14
- data.value = snapshot.val();
15
- }
16
- docRef.on('value', update);
17
- if (autoDispose) {
18
- tryOnScopeDispose(() => {
19
- docRef.off('value', update);
20
- });
21
- }
22
- return data;
4
+ function useRTDB(docRef, options = {}) {
5
+ const {
6
+ autoDispose = true
7
+ } = options;
8
+ const data = ref(void 0);
9
+ function update(snapshot) {
10
+ data.value = snapshot.val();
11
+ }
12
+ docRef.on("value", update);
13
+ if (autoDispose) {
14
+ tryOnScopeDispose(() => {
15
+ docRef.off("value", update);
16
+ });
17
+ }
18
+ return data;
23
19
  }
24
20
 
25
21
  export { useRTDB };