fixed some flow and eslint errors
This commit is contained in:
parent
6cee2609b1
commit
80b519158f
|
@ -83,7 +83,12 @@ export default class Database extends Base {
|
|||
* @param origCB
|
||||
* @returns {*}
|
||||
*/
|
||||
off(refId: number, listeners: Array<DatabaseListener>, remainingListenersCount: number) {
|
||||
off(
|
||||
refId: number,
|
||||
// $FlowFixMe
|
||||
listeners: Array<DatabaseListener>,
|
||||
remainingListenersCount: number
|
||||
) {
|
||||
this.log.debug('off() : ', refId, listeners);
|
||||
|
||||
// Delete the reference if there are no more listeners
|
||||
|
|
|
@ -26,9 +26,13 @@ declare type FuncSnapshotType = null|(snapshot: UploadTaskSnapshotType) => any;
|
|||
|
||||
declare type FuncErrorType = null|(error: Error) => any;
|
||||
|
||||
declare type NextOrObserverType = null
|
||||
|{ next?: FuncSnapshotType, error?: FuncErrorType, complete?:FuncSnapshotType }
|
||||
|FuncSnapshotType;
|
||||
declare type NextOrObserverType = null |
|
||||
{
|
||||
next?: FuncSnapshotType,
|
||||
error?: FuncErrorType,
|
||||
complete?:FuncSnapshotType
|
||||
} |
|
||||
FuncSnapshotType;
|
||||
|
||||
/**
|
||||
* @url https://firebase.google.com/docs/reference/js/firebase.storage.UploadTask
|
||||
|
@ -93,15 +97,41 @@ export default class StorageTask {
|
|||
* @private
|
||||
*/
|
||||
_subscribe(nextOrObserver: NextOrObserverType, error: FuncErrorType, complete: FuncSnapshotType): Function {
|
||||
const observer = isObject(nextOrObserver);
|
||||
let _error;
|
||||
let _next;
|
||||
let _complete;
|
||||
|
||||
const _error = this._interceptErrorEvent(observer ? nextOrObserver.error : error);
|
||||
const _next = this._interceptSnapshotEvent(observer ? nextOrObserver.next : nextOrObserver);
|
||||
const _complete = this._interceptSnapshotEvent(observer ? nextOrObserver.complete : complete);
|
||||
if (typeof nextOrObserver === 'function') {
|
||||
_error = this._interceptErrorEvent(error);
|
||||
_next = this._interceptSnapshotEvent(nextOrObserver);
|
||||
_complete = this._interceptSnapshotEvent(complete);
|
||||
} else if (nextOrObserver) {
|
||||
_error = this._interceptErrorEvent(nextOrObserver.error);
|
||||
_next = this._interceptSnapshotEvent(nextOrObserver.next);
|
||||
_complete = this._interceptSnapshotEvent(nextOrObserver.complete);
|
||||
}
|
||||
|
||||
if (_next) this.storage._addListener(this.path, StorageStatics.TaskEvent.STATE_CHANGED, _next);
|
||||
if (_error) this.storage._addListener(this.path, `${this.type}_failure`, _error);
|
||||
if (_complete) this.storage._addListener(this.path, `${this.type}_success`, _complete);
|
||||
if (_next) {
|
||||
this.storage._addListener(
|
||||
this.path,
|
||||
StorageStatics.TaskEvent.STATE_CHANGED,
|
||||
_next
|
||||
);
|
||||
}
|
||||
if (_error) {
|
||||
this.storage._addListener(
|
||||
this.path,
|
||||
`${this.type}_failure`,
|
||||
_error
|
||||
);
|
||||
}
|
||||
if (_complete) {
|
||||
this.storage._addListener(
|
||||
this.path,
|
||||
`${this.type}_success`,
|
||||
_complete
|
||||
);
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (_next) this.storage._removeListener(this.path, StorageStatics.TaskEvent.STATE_CHANGED, _next);
|
||||
|
|
Loading…
Reference in New Issue