mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-28 20:25:41 +08:00
fixed some flow and eslint errors
This commit is contained in:
@@ -80,7 +80,7 @@ export default class StorageReference extends ReferenceBase {
|
||||
* Alias to putFile
|
||||
* @returns {StorageReference.putFile}
|
||||
*/
|
||||
get put() {
|
||||
get put(): Function {
|
||||
return this.putFile;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,11 +11,13 @@ declare type UploadTaskSnapshotType = {
|
||||
downloadURL: string|null,
|
||||
metadata: Object, // TODO flow type def for https://firebase.google.com/docs/reference/js/firebase.storage.FullMetadata.html
|
||||
ref: StorageReference,
|
||||
state: StorageStatics.TaskState.RUNNING
|
||||
|StorageStatics.TaskState.PAUSED
|
||||
|StorageStatics.TaskState.SUCCESS
|
||||
|StorageStatics.TaskState.CANCELLED
|
||||
|StorageStatics.TaskState.ERROR,
|
||||
state: (
|
||||
typeof StorageStatics.TaskState.RUNNING
|
||||
| typeof StorageStatics.TaskState.PAUSED
|
||||
| typeof StorageStatics.TaskState.SUCCESS
|
||||
| typeof StorageStatics.TaskState.CANCELLED
|
||||
| typeof StorageStatics.TaskState.ERROR
|
||||
),
|
||||
task: StorageTask,
|
||||
totalBytes: number,
|
||||
};
|
||||
@@ -32,7 +34,14 @@ declare type NextOrObserverType = null
|
||||
* @url https://firebase.google.com/docs/reference/js/firebase.storage.UploadTask
|
||||
*/
|
||||
export default class StorageTask {
|
||||
constructor(type: UPLOAD_TASK|DOWNLOAD_TASK, promise: Promise, storageRef: StorageReference) {
|
||||
type: typeof UPLOAD_TASK | typeof DOWNLOAD_TASK
|
||||
ref: StorageReference
|
||||
storage: StorageReference.storage
|
||||
path: StorageReference.path
|
||||
then: Promise<*>
|
||||
catch: () => Promise<*>
|
||||
|
||||
constructor(type: typeof UPLOAD_TASK | typeof DOWNLOAD_TASK, promise: Promise<*>, storageRef: StorageReference) {
|
||||
this.type = type;
|
||||
this.ref = storageRef;
|
||||
this.storage = storageRef.storage;
|
||||
@@ -49,13 +58,13 @@ export default class StorageTask {
|
||||
* @returns {Promise.<T>}
|
||||
* @private
|
||||
*/
|
||||
_interceptSnapshotEvent(f: Function|null|undefined): null|() => any {
|
||||
_interceptSnapshotEvent(f: ?Function): null | () => * {
|
||||
if (!isFunction(f)) return null;
|
||||
return (snapshot) => {
|
||||
const _snapshot = Object.assign({}, snapshot);
|
||||
_snapshot.task = this;
|
||||
_snapshot.ref = this.ref;
|
||||
return f(_snapshot);
|
||||
return f && f(_snapshot);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -65,12 +74,13 @@ export default class StorageTask {
|
||||
* @returns {*}
|
||||
* @private
|
||||
*/
|
||||
_interceptErrorEvent(f: Function|null|undefined): null|() => any {
|
||||
_interceptErrorEvent(f: ?Function): null | (Error) => * {
|
||||
if (!isFunction(f)) return null;
|
||||
return (error) => {
|
||||
const _error = new Error(error.message);
|
||||
// $FlowFixMe
|
||||
_error.code = error.code;
|
||||
return f(_error);
|
||||
return f && f(_error);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user