firex-store
Advanced tools
Comparing version 0.7.0 to 0.7.1
@@ -5,3 +5,3 @@ import { CriteriaOptions } from './criteria-options.interface'; | ||
/** | ||
* @param afterMutationCalled convert subscribed data to something, if defined | ||
* @param afterMutationCalled This method called after mutation called | ||
* - `subscribeFirestore` and `subscribeFirestoreActions` only. | ||
@@ -8,0 +8,0 @@ * - type: (payload: Payload) => void |
@@ -1,3 +0,3 @@ | ||
export * from './map-to-if-defined'; | ||
export * from './mutation-handlers'; | ||
export * from './notifications'; | ||
export * from './to-document-result'; |
@@ -6,4 +6,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./map-to-if-defined")); | ||
__export(require("./mutation-handlers")); | ||
__export(require("./notifications")); | ||
__export(require("./to-document-result")); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const map_to_if_defined_1 = require("./map-to-if-defined"); | ||
const to_document_result_1 = require("./to-document-result"); | ||
exports.callDocumentMutation = ({ snapshot, callMutation, isLast, type, mapper, afterMutationCalled }) => { | ||
const _type = type ? type : 'added'; | ||
const _isLast = typeof isLast !== 'undefined' ? isLast : true; | ||
const data = map_to_if_defined_1.mapToIfDefined(snapshot, mapper); | ||
const data = to_document_result_1.toDocumentResult(snapshot, mapper); | ||
const payload = { data, isLast: _isLast }; | ||
@@ -9,0 +9,0 @@ callMutation(_type, payload); |
@@ -6,6 +6,6 @@ "use strict"; | ||
static subscribe({ ref, callMutation, mapper, errorHandler, completionHandler, afterMutationCalled, notFoundHandler, onCompleted }) { | ||
return ref.onSnapshot((doc) => !doc.exists | ||
return ref.onSnapshot((snapshot) => !snapshot.exists | ||
? helpers_1.notifyNotFound('document', notFoundHandler) | ||
: helpers_1.callDocumentMutation({ | ||
snapshot: doc, | ||
snapshot, | ||
callMutation, | ||
@@ -30,3 +30,3 @@ mapper, | ||
.get() | ||
.then((doc) => (!doc.exists ? null : helpers_1.mapToIfDefined(doc, mapper))) | ||
.then((doc) => (!doc.exists ? null : helpers_1.toDocumentResult(doc, mapper))) | ||
.catch((error) => helpers_1.notifyErrorOccurred(error, errorHandler)); | ||
@@ -41,3 +41,3 @@ helpers_1.notifyCompletionIfDefined(completionHandler ? completionHandler : onCompleted); | ||
? [] | ||
: snapshot.docs.map((doc) => !doc.exists ? null : helpers_1.mapToIfDefined(doc, mapper))) | ||
: snapshot.docs.map((doc) => !doc.exists ? null : helpers_1.toDocumentResult(doc, mapper))) | ||
.then((documentResults) => { | ||
@@ -44,0 +44,0 @@ const resultsWithoutNull = documentResults.filter((it) => it !== null); |
{ | ||
"name": "firex-store", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"description": "subscribe firebase data to vuex", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -329,2 +329,10 @@ # firex-store | ||
- notFoundHandler | ||
- If it defined, call it when snapshot doesn't exist | ||
- type: 'document' | 'collection' | ||
- isAll: | ||
- undefined when subscribe Document data | ||
- true when subscribe Collection data | ||
- false when subscribe Collection data and document in Collection is not existed | ||
Ex. | ||
@@ -366,2 +374,8 @@ | ||
```javascript | ||
const notFoundHandler = (type, isAll) => { | ||
console.log('not found') | ||
} | ||
``` | ||
```javascript | ||
export default { | ||
@@ -386,4 +400,5 @@ namespaced: true, | ||
completionHandler, | ||
// onCompleted, <- obsoleted | ||
afterMutationCalled | ||
// onCompleted, <- deprecated | ||
afterMutationCalled, | ||
notFoundHandler | ||
} | ||
@@ -390,0 +405,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38504
409