| 71 | } |
| 72 | |
| 73 | export class OnDisconnect implements IOnDisconnect { |
| 74 | _native: FIRDatabaseReference; |
| 75 | |
| 76 | static fromNative(disconnect: FIRDatabaseReference) { |
| 77 | if (disconnect instanceof FIRDatabaseReference) { |
| 78 | const d = new OnDisconnect(); |
| 79 | d._native = disconnect; |
| 80 | return d; |
| 81 | } |
| 82 | return null; |
| 83 | } |
| 84 | |
| 85 | get native() { |
| 86 | return this._native; |
| 87 | } |
| 88 | |
| 89 | get ios() { |
| 90 | return this.native; |
| 91 | } |
| 92 | |
| 93 | cancel(onComplete?: (error: FirebaseError) => void): Promise<void> { |
| 94 | return new Promise((resolve, reject) => { |
| 95 | if (!this.native) { |
| 96 | reject(); |
| 97 | } else { |
| 98 | this.native.cancelDisconnectOperationsWithCompletionBlock((error, ref) => { |
| 99 | if (error) { |
| 100 | const err = FirebaseError.fromNative(error); |
| 101 | onComplete?.(err); |
| 102 | reject(err); |
| 103 | } else { |
| 104 | onComplete?.(null); |
| 105 | resolve(); |
| 106 | } |
| 107 | }); |
| 108 | } |
| 109 | }); |
| 110 | } |
| 111 | |
| 112 | remove(onComplete?: (error: FirebaseError) => void): Promise<void> { |
| 113 | return new Promise((resolve, reject) => { |
| 114 | this.native.onDisconnectRemoveValueWithCompletionBlock((error, ref) => { |
| 115 | if (error) { |
| 116 | const err = FirebaseError.fromNative(error); |
| 117 | onComplete?.(err); |
| 118 | reject(err); |
| 119 | } else { |
| 120 | onComplete?.(null); |
| 121 | resolve(); |
| 122 | } |
| 123 | }); |
| 124 | }); |
| 125 | } |
| 126 | |
| 127 | set(value: any, onComplete?: (error: FirebaseError) => void): Promise<void> { |
| 128 | return new Promise((resolve, reject) => { |
| 129 | this.native.onDisconnectSetValueWithCompletionBlock(serializeItems(value), (error, ref) => { |
| 130 | if (error) { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…