import { FirestoreRef, Context } from '../../types'; import { FirestoreSubscriber, FirestoreFinder, FirestoreStreamSubscriber } from '../../services'; import { Action } from 'stream-executor'; /** * Factory of FirestoreSubscriber and FirestoreFinder * @param ref: firebase.firestore.DocumentReference | firebase.firestore.CollectionReference | firebase.firestore.Query * @method bindTo(statePropName): return FirestoreSubscriber * @method once: return FirestoreFinder * @method pipe(...args): return FirestoreStreamSubscriber */ export declare class FirestoreReaderServiceFactory { private _ref; constructor(ref: FirestoreRef); /** * Return FirestoreSubscriber instance * @param statePropName: state property bound to firestore data * @return FirestoreSubscriber */ bindTo(statePropName: string): FirestoreSubscriber; /** * Return FirestoreFinder instance * @return FirestoreFinder */ once(): FirestoreFinder; /** * Subscribe firestore data like rxjs. * @see see a comparison of usage with `from(ref).bindTo(statePropName)` * https://github.com/nor-ko-hi-jp/firex-store/blob/master/docs/v1/v1-usage.md#subscribe-firestore-using-like-rxjs * @description If you'd like to use helper method in pipe function, use stream-executor library. * https://github.com/nor-ko-hi-jp/stream-executor#helper-methods-and-those-descriptions-in-createstream-are * @param act1 (data: { isLast: boolean, data: T, bindTo: (statePropName: string) => void }) => U * @param act2 (data: T) => U * @param act3 (data: T) => U * @param act4 (data: T) => U * @param act5 (data: T) => U * @param act6 (data: T) => U * @param act7 (data: T) => U * @param act8 (data: T) => U * @param act9 (data: T) => U * @param act10 (data: T) => U * * @example * import { from, map, bndTo, firestoreMutations } from 'firex-store' * * const toCharactor = (data) => ({ id: data.docId, name: `${data.first_name} ${data.family_name}` }) * * export default { * state: { * charactors: null, * isLoaded: false * }, * mutations: { * ...firestoreMutations('all'), * setIsLoaded: (state, paylaod) => { * state.charactors = payload * } * }, * actions: { * subscribe: ({ commit, state }, { collectionName }) => { * from(firebase.collections(collectionName)) * .pipe( * map(toCharactor), * bindTo('charactor'), * ({ data }) => { * commit('setIsLoaded', data) * } * ) * .subscribe(state, commit) * } * } * } */ pipe(act1: Action>, A>, act2?: Action, act3?: Action, act4?: Action, act5?: Action, act6?: Action, act7?: Action, act8?: Action, act9?: Action, act10?: Action): Pick; }