firex-store
Advanced tools
Comparing version 0.7.1 to 0.8.0
@@ -7,3 +7,12 @@ import { FindCriteriaOptions } from './options'; | ||
} | ||
/** | ||
* @description fetch firestore data at once | ||
* @param ref firebase.firestore.DocumentReference | firebase.firestore.CollectionReference | firebase.firestore.Query | ||
* @param options optional methods. can undefined | ||
* - mapper | ||
* - errorHandler | ||
* - completionHandler | ||
* - onCompleted `deprecated` | ||
*/ | ||
export declare const findFirestore: <T = any>({ ref, options }: Criteria<FirestoreRef, T>) => Promise<NullOr<T>>; | ||
export {}; |
@@ -5,2 +5,11 @@ "use strict"; | ||
const is_document_ref_1 = require("./store/helpers/is-document-ref"); | ||
/** | ||
* @description fetch firestore data at once | ||
* @param ref firebase.firestore.DocumentReference | firebase.firestore.CollectionReference | firebase.firestore.Query | ||
* @param options optional methods. can undefined | ||
* - mapper | ||
* - errorHandler | ||
* - completionHandler | ||
* - onCompleted `deprecated` | ||
*/ | ||
exports.findFirestore = ({ ref, options }) => { | ||
@@ -7,0 +16,0 @@ return is_document_ref_1.isDocumentRef(ref) |
@@ -5,10 +5,17 @@ import { CriteriaOptions } from './criteria-options.interface'; | ||
/** | ||
* @param afterMutationCalled This method called after mutation called | ||
* @description afterMutationCalled This method called after mutation called | ||
* - `subscribeFirestore` and `subscribeFirestoreActions` only. | ||
* - type: (payload: Payload) => void | ||
* - payload = { data: { docId: string, [key: string]: any }, isLast: boolean } | ||
* @param: (payload: Payload) => void | ||
* + payload = { data: { docId: string, [key: string]: any }, isLast: boolean } | ||
* + data: subscribed data | ||
* + isLast: | ||
* + undefined: subscribed 'document' data | ||
* + true: subscribed multiple data(subscribe 'collection' data), and it is last data | ||
* + false: subscribed multiple data(subscribe 'collection' data), and it is not last data | ||
* `UseCase`: appear and disappear loading bar when subscribe at first. | ||
* | ||
*/ | ||
afterMutationCalled?: AfterMutationCalled; | ||
/** | ||
* @param notFoundHandler (type?: string, isAll?: boolean) => void | ||
* @description (type?: string, isAll?: boolean) => void | ||
* - type: 'document' | 'collection' | ||
@@ -15,0 +22,0 @@ * - isAll: |
@@ -6,5 +6,4 @@ "use strict"; | ||
const _type = type ? type : 'added'; | ||
const _isLast = typeof isLast !== 'undefined' ? isLast : true; | ||
const data = to_document_result_1.toDocumentResult(snapshot, mapper); | ||
const payload = { data, isLast: _isLast }; | ||
const payload = { data, isLast }; | ||
callMutation(_type, payload); | ||
@@ -11,0 +10,0 @@ if (afterMutationCalled) { |
@@ -9,3 +9,15 @@ import { ActionTree } from 'vuex'; | ||
} | ||
/** | ||
* @description subscribe firestore data to state property | ||
* @param actionName custom action name. can undefined | ||
* @param ref firebase.firestore.DocumentReference | firebase.firestore.CollectionReference | firebase.firestore.Query | ||
* @param options optional methods. can undefined | ||
* - mapper | ||
* - errorHandler | ||
* - completionHandler | ||
* - notFoundHandler | ||
* - afterMutationCalled | ||
* - onCompleted `deprecated` | ||
*/ | ||
export declare const firestoreSubscribeActions: <T = any>({ ref, actionName, options }: Criteria<T>) => ActionTree<any, any>; | ||
export {}; |
@@ -5,2 +5,14 @@ "use strict"; | ||
const helpers_1 = require("../helpers"); | ||
/** | ||
* @description subscribe firestore data to state property | ||
* @param actionName custom action name. can undefined | ||
* @param ref firebase.firestore.DocumentReference | firebase.firestore.CollectionReference | firebase.firestore.Query | ||
* @param options optional methods. can undefined | ||
* - mapper | ||
* - errorHandler | ||
* - completionHandler | ||
* - notFoundHandler | ||
* - afterMutationCalled | ||
* - onCompleted `deprecated` | ||
*/ | ||
exports.firestoreSubscribeActions = ({ ref, actionName, options }) => { | ||
@@ -7,0 +19,0 @@ const defaultActionName = helpers_1.isDocumentRef(ref) |
@@ -7,3 +7,8 @@ import { MutationType } from '../../types'; | ||
} | ||
/** | ||
* @description unsubscribe firestore data | ||
* @param type 'document' | 'collection' | ||
* @param actionName can undefined. But if you define actionName in `firestoreSubscribeActions`, set same name. | ||
*/ | ||
export declare const firestoreUnsubscribeActions: ({ type, actionName }: Criteria) => ActionTree<any, any>; | ||
export {}; |
@@ -5,2 +5,7 @@ "use strict"; | ||
const helpers_1 = require("../helpers"); | ||
/** | ||
* @description unsubscribe firestore data | ||
* @param type 'document' | 'collection' | ||
* @param actionName can undefined. But if you define actionName in `firestoreSubscribeActions`, set same name. | ||
*/ | ||
exports.firestoreUnsubscribeActions = ({ type, actionName }) => { | ||
@@ -7,0 +12,0 @@ const defaultActionName = type === 'document' |
@@ -10,3 +10,16 @@ import { Commit } from 'vuex'; | ||
} | ||
/** | ||
* @description subscribe firestore data to state property | ||
* @param state vuex's state | ||
* @param commit vuex's commit | ||
* @param ref firebase.firestore.DocumentReference | firebase.firestore.CollectionReference | firebase.firestore.Query | ||
* @param options optional methods. can undefined | ||
* - mapper | ||
* - errorHandler | ||
* - completionHandler | ||
* - notFoundHandler | ||
* - afterMutationCalled | ||
* - onCompleted `deprecated` | ||
*/ | ||
export declare const subscribeFirestore: <T = any>({ state, commit, ref, options }: Criteria<FirestoreRef, T>) => void; | ||
export {}; |
@@ -31,2 +31,15 @@ "use strict"; | ||
}; | ||
/** | ||
* @description subscribe firestore data to state property | ||
* @param state vuex's state | ||
* @param commit vuex's commit | ||
* @param ref firebase.firestore.DocumentReference | firebase.firestore.CollectionReference | firebase.firestore.Query | ||
* @param options optional methods. can undefined | ||
* - mapper | ||
* - errorHandler | ||
* - completionHandler | ||
* - notFoundHandler | ||
* - afterMutationCalled | ||
* - onCompleted `deprecated` | ||
*/ | ||
exports.subscribeFirestore = ({ state, commit, ref, options }) => { | ||
@@ -33,0 +46,0 @@ is_document_ref_1.isDocumentRef(ref) |
@@ -6,3 +6,8 @@ import { MutationType } from '../../types'; | ||
} | ||
/** | ||
* @description unsubscribe firestore data | ||
* @param type 'document' | 'collection' | ||
* @param state any. vuex's state | ||
*/ | ||
export declare const unsubscribeFirestore: ({ state, type }: Criteria) => void; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const configurations_1 = require("../configurations"); | ||
/** | ||
* @description unsubscribe firestore data | ||
* @param type 'document' | 'collection' | ||
* @param state any. vuex's state | ||
*/ | ||
exports.unsubscribeFirestore = ({ state, type }) => { | ||
@@ -5,0 +10,0 @@ const prop = type === 'document' |
{ | ||
"name": "firex-store", | ||
"version": "0.7.1", | ||
"version": "0.8.0", | ||
"description": "subscribe firebase data to vuex", | ||
@@ -17,3 +17,5 @@ "main": "./lib/index.js", | ||
"prepublishOnly": "npm test && npm run lint", | ||
"preversion": "npm run lint" | ||
"preversion": "npm run lint", | ||
"version": "npm run format && git add -A src", | ||
"postversion": "git push && git push --tags" | ||
}, | ||
@@ -42,11 +44,11 @@ "repository": { | ||
"@types/jest": "^24.0.18", | ||
"@typescript-eslint/eslint-plugin": "^2.2.0", | ||
"@typescript-eslint/parser": "^2.3.0", | ||
"@typescript-eslint/eslint-plugin": "^2.3.2", | ||
"@typescript-eslint/parser": "^2.3.2", | ||
"@vue/test-utils": "^1.0.0-beta.29", | ||
"babel-plugin-transform-object-rest-spread": "^6.26.0", | ||
"babel-preset-env": "^1.7.0", | ||
"eslint": "^6.3.0", | ||
"eslint": "^6.5.1", | ||
"eslint-config-prettier": "^6.3.0", | ||
"eslint-plugin-prettier": "^3.1.0", | ||
"firebase": "^6.6.2", | ||
"eslint-plugin-prettier": "^3.1.1", | ||
"firebase": "^7.1.0", | ||
"jest": "^24.9.0", | ||
@@ -53,0 +55,0 @@ "prettier": "^1.18.2", |
@@ -328,7 +328,14 @@ # firex-store | ||
- This method called after mutation called | ||
- @param payload | ||
- type payload = { | ||
- data: { docId: string | null, [key: string]: any }, <-- subscribed data | ||
- isLast: boolean, <-- In 'document' subscribed , it undefined. In 'collection' subscribed, true or false. | ||
- UseCase: disappear and appear loading bar when subscribed 'collection' data at first | ||
- [key: string]: any } | ||
- notFoundHandler | ||
- If it defined, call it when snapshot doesn't exist | ||
- type: 'document' | 'collection' | ||
- isAll: | ||
- @param type: 'document' | 'collection' | ||
- @param isAll: | ||
- undefined when subscribe Document data | ||
@@ -369,3 +376,7 @@ - true when subscribe Collection data | ||
* */ | ||
console.log(payload) | ||
if (payload.isLast === false) { | ||
commit('SET_LOADING', true) | ||
} else if (payload.isLast === true) { | ||
commit('SET_LOADING', false) | ||
} | ||
} | ||
@@ -381,2 +392,8 @@ ``` | ||
```javascript | ||
const notFoundHandler = (type, isAll) => { | ||
console.log('not found') | ||
} | ||
``` | ||
```javascript | ||
export default { | ||
@@ -386,6 +403,10 @@ namespaced: true, | ||
comments: [], | ||
comment: null | ||
comment: null, | ||
isLoading: false | ||
}, | ||
mutations: { | ||
...firestoreMutations({ statePropName: 'users', type: 'document' }) | ||
...firestoreMutations({ statePropName: 'comments', type: 'collection' }), | ||
SET_LOADING(state, isLoading) { | ||
state.isLoading = isLoading | ||
} | ||
}, | ||
@@ -397,3 +418,3 @@ actions: { | ||
commit, | ||
ref: firestore.collection('/users').doc('userId'), | ||
ref: firestore.collection('/comments'), | ||
options: { | ||
@@ -400,0 +421,0 @@ mapper: mapUser, |
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
42655
762
430