UNPKG

4.11 kBTypeScriptView Raw
1import * as Firebase from 'firebase';
2import { Dispatch } from 'redux';
3
4/**
5 * Action types used within actions dispatched internally. These action types
6 * can be manually dispatched to update state.
7 */
8export const actionTypes: {
9 START: string;
10 ERROR: string;
11 CLEAR_DATA: string;
12 CLEAR_ERROR: string;
13 CLEAR_ERRORS: string;
14 SET_LISTENER: string;
15 UNSET_LISTENER: string;
16 GET_REQUEST: string;
17 GET_SUCCESS: string;
18 GET_FAILURE: string;
19 SET_REQUEST: string;
20 SET_SUCCESS: string;
21 SET_FAILURE: string;
22 ADD_REQUEST: string;
23 ADD_SUCCESS: string;
24 ADD_FAILURE: string;
25 UPDATE_REQUEST: string;
26 UPDATE_SUCCESS: string;
27 UPDATE_FAILURE: string;
28 DELETE_REQUEST: string;
29 DELETE_SUCCESS: string;
30 DELETE_FAILURE: string;
31 ATTACH_LISTENER: string;
32 LISTENER_RESPONSE: string;
33 LISTENER_ERROR: string;
34 ON_SNAPSHOT_REQUEST: string;
35 ON_SNAPSHOT_SUCCESS: string;
36 ON_SNAPSHOT_FAILURE: string;
37};
38
39/**
40 * Constants used within redux-firetore. Includes actionTypes, actionsPrefix,
41 * and default config.
42 */
43export const constants: {
44 actionTypes: {
45 START: string;
46 ERROR: string;
47 CLEAR_DATA: string;
48 CLEAR_ERROR: string;
49 CLEAR_ERRORS: string;
50 SET_LISTENER: string;
51 UNSET_LISTENER: string;
52 GET_REQUEST: string;
53 GET_SUCCESS: string;
54 GET_FAILURE: string;
55 SET_REQUEST: string;
56 SET_SUCCESS: string;
57 SET_FAILURE: string;
58 ADD_REQUEST: string;
59 ADD_SUCCESS: string;
60 ADD_FAILURE: string;
61 UPDATE_REQUEST: string;
62 UPDATE_SUCCESS: string;
63 UPDATE_FAILURE: string;
64 DELETE_REQUEST: string;
65 DELETE_SUCCESS: string;
66 DELETE_FAILURE: string;
67 ATTACH_LISTENER: string;
68 LISTENER_RESPONSE: string;
69 LISTENER_ERROR: string;
70 ON_SNAPSHOT_REQUEST: string;
71 ON_SNAPSHOT_SUCCESS: string;
72 ON_SNAPSHOT_FAILURE: string;
73 };
74 actionsPrefix: string;
75 defaultConfig: Config;
76};
77
78export interface Config {
79 enableLogging: boolean;
80
81 helpersNamespace: string | null;
82
83 // https://github.com/prescottprue/redux-firestore#loglistenererror
84 logListenerError: boolean;
85
86 // https://github.com/prescottprue/redux-firestore#enhancernamespace
87 enhancerNamespace: string;
88
89 // https://github.com/prescottprue/redux-firestore#allowmultiplelisteners
90 allowMultipleListeners:
91 | ((listenerToAttach: any, currentListeners: any) => boolean)
92 | boolean;
93
94 // https://github.com/prescottprue/redux-firestore#preserveondelete
95 preserveOnDelete: null | object;
96
97 // https://github.com/prescottprue/redux-firestore#preserveonlistenererror
98 preserveOnListenerError: null | object;
99
100 // https://github.com/prescottprue/redux-firestore#onattemptcollectiondelete
101 onAttemptCollectionDelete: null | ((queryOption: string, dispatch: Dispatch, firebase: Object) => void);
102
103 // https://github.com/prescottprue/redux-firestore#mergeordered
104 mergeOrdered: boolean;
105
106 // https://github.com/prescottprue/redux-firestore#mergeordereddocupdate
107 mergeOrderedDocUpdate: boolean;
108
109 // https://github.com/prescottprue/redux-firestore#mergeorderedcollectionupdates
110 mergeOrderedCollectionUpdates: boolean;
111}
112
113/**
114 * A redux store enhancer that adds store.firebase (passed to React component
115 * context through react-redux's <Provider>).
116 */
117export function reduxFirestore(
118 firebaseInstance: typeof Firebase,
119 otherConfig?: Partial<Config>,
120): any;
121
122/**
123 * Get extended firestore instance (attached to store.firestore)
124 */
125export function getFirestore(
126 firebaseInstance: typeof Firebase,
127 otherConfig?: Partial<Config>,
128): any;
129
130/**
131 * A redux store reducer for Firestore state
132 */
133export function firestoreReducer(state: object, action: object): any;
134
135/**
136 * Create a firestore instance that has helpers attached for dispatching actions
137 */
138export function createFirestoreInstance(
139 firebaseInstance: typeof Firebase,
140 configs: Partial<Config>,
141 dispatch: Dispatch,
142): object;
143
144/**
145 * A redux store reducer for Firestore state
146 */
147export namespace firestoreReducer {
148 const prototype: {};
149}
150
151/**
152 * A redux store reducer for Firestore state
153 */
154export namespace reduxFirestore {
155 const prototype: {};
156}
157
\No newline at end of file