MCPcopy Index your code
hub / github.com/NativeScript/firebase / on

Method on

packages/firebase-storage/index.ios.ts:119–184  ·  view source on GitHub ↗
(event: TaskEvent, nextOrObserver?: TaskSnapshotObserver | ((a: TaskSnapshot) => any), error?: (a: FirebaseError) => any, complete?: () => void)

Source from the content-addressed store, hash-verified

117 }
118
119 on(event: TaskEvent, nextOrObserver?: TaskSnapshotObserver | ((a: TaskSnapshot) => any), error?: (a: FirebaseError) => any, complete?: () => void) {
120 if (event !== TaskEvent.STATE_CHANGED) {
121 return;
122 }
123
124 if (nextOrObserver) {
125 if (typeof nextOrObserver === 'function') {
126 this.native.observeStatusHandler(FIRStorageTaskStatus.Progress, (snapshot) => {
127 nextOrObserver(TaskSnapshot.fromNative(snapshot));
128 });
129
130 this.native.observeStatusHandler(FIRStorageTaskStatus.Pause, (snapshot) => {
131 nextOrObserver(TaskSnapshot.fromNative(snapshot));
132 });
133
134 this.native.observeStatusHandler(FIRStorageTaskStatus.Resume, (snapshot) => {
135 nextOrObserver(TaskSnapshot.fromNative(snapshot));
136 });
137 } else if (typeof nextOrObserver === 'object') {
138 this.native.observeStatusHandler(FIRStorageTaskStatus.Progress, (snapshot) => {
139 nextOrObserver?.next(TaskSnapshot.fromNative(snapshot));
140 });
141
142 this.native.observeStatusHandler(FIRStorageTaskStatus.Pause, (snapshot) => {
143 nextOrObserver?.next(TaskSnapshot.fromNative(snapshot));
144 });
145
146 this.native.observeStatusHandler(FIRStorageTaskStatus.Resume, (snapshot) => {
147 nextOrObserver?.next(TaskSnapshot.fromNative(snapshot));
148 });
149 }
150 }
151
152 if (error || typeof nextOrObserver === 'function' || typeof nextOrObserver === 'object') {
153 this.native.observeStatusHandler(FIRStorageTaskStatus.Failure, (snapshot) => {
154 if (nextOrObserver) {
155 if (typeof nextOrObserver === 'function') {
156 nextOrObserver(TaskSnapshot.fromNative(snapshot));
157 } else if (typeof nextOrObserver === 'object') {
158 nextOrObserver?.next(TaskSnapshot.fromNative(snapshot));
159 nextOrObserver?.error(FirebaseError.fromNative(snapshot.error));
160 }
161 }
162
163 if (error) {
164 error(FirebaseError.fromNative(snapshot.error));
165 }
166 });
167 }
168
169 if (complete || typeof nextOrObserver === 'function' || typeof nextOrObserver === 'object') {
170 this.native.observeStatusHandler(FIRStorageTaskStatus.Success, (snapshot) => {
171 if (nextOrObserver) {
172 if (typeof nextOrObserver === 'function') {
173 nextOrObserver(TaskSnapshot.fromNative(snapshot));
174 } else if (typeof nextOrObserver === 'object') {
175 nextOrObserver?.next(TaskSnapshot.fromNative(snapshot));
176 nextOrObserver?.complete?.();

Callers

nothing calls this directly

Calls 4

completeMethod · 0.80
fromNativeMethod · 0.45
nextMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected