How to use the @react-native-firebase/app/lib/common.isFunction function in @react-native-firebase/app

To help you get started, we’ve selected a few @react-native-firebase/app examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github invertase / react-native-firebase / packages / messaging / lib / index.js View on Github external
onMessage(listener) {
    if (!isFunction(listener)) {
      throw new Error("firebase.messaging().onMessage(*) 'listener' expected a function.");
    }

    // TODO(salakar) rework internals as without this native module will never be ready (therefore never subscribes)
    this.native;

    const subscription = this.emitter.addListener('messaging_message_received', listener);
    return () => subscription.remove();
  }
github invertase / react-native-firebase / packages / storage / lib / StorageTask.js View on Github external
function wrapSnapshotEventListener(task, listenerFn, unsubscribe) {
  if (!isFunction(listenerFn)) {
    return null;
  }
  return event => {
    if (unsubscribe) {
      setTimeout(() => unsubscribe(), 0);
    } // 1 frame = 16ms, pushing to next frame
    if (isFunction(listenerFn)) {
      const snapshot = Object.assign({}, event);
      snapshot.task = task;
      snapshot.ref = task._ref;

      if (snapshot.metadata) {
        if (!snapshot.metadata.generation) {
          snapshot.metadata.generation = '';
        }
        if (!snapshot.metadata.bucket) {
github invertase / react-native-firebase / packages / database / lib / DatabaseReference.js View on Github external
set(value, onComplete) {
    if (isUndefined(value)) {
      throw new Error("firebase.database().ref().set(*) 'value' must be defined.");
    }

    if (!isUndefined(onComplete) && !isFunction(onComplete)) {
      throw new Error(
        "firebase.database().ref().set(_, *) 'onComplete' must be a function if provided.",
      );
    }

    return promiseWithOptionalCallback(this._database.native.set(this.path, { value }), onComplete);
  }
github invertase / react-native-firebase / packages / storage / lib / StorageTask.js View on Github external
let _complete;
  let _completeSubscription;

  const unsubscribe = () => {
    if (_nextSubscription) {
      _nextSubscription.remove();
    }
    if (_errorSubscription) {
      _errorSubscription.remove();
    }
    if (_completeSubscription) {
      _completeSubscription.remove();
    }
  };

  if (isFunction(nextOrObserver)) {
    _error = wrapErrorEventListener(error, unsubscribe);
    _next = wrapSnapshotEventListener(task, nextOrObserver);
    _complete = wrapSnapshotEventListener(task, complete, unsubscribe);
  } else if (isObject(nextOrObserver)) {
    _error = wrapErrorEventListener(nextOrObserver.error, unsubscribe);
    _next = wrapSnapshotEventListener(task, nextOrObserver.next);
    _complete = wrapSnapshotEventListener(task, nextOrObserver.complete, unsubscribe);
  } else if (isNull(nextOrObserver)) {
    _error = wrapErrorEventListener(error, unsubscribe);
    _complete = wrapSnapshotEventListener(task, complete, unsubscribe);
  } else {
    throw new Error(
      "firebase.storage.StorageTask.on(*, _) 'nextOrObserver' must be a Function, an Object or Null.",
    );
  }
github invertase / react-native-firebase / packages / auth / lib / PhoneAuthListener.js View on Github external
);
    }

    if (!isFunction(observer)) {
      throw new Error(
        "firebase.auth.PhoneAuthListener.on(_, *, _, _) 'observer' must be a function.",
      );
    }

    this._addUserObserver(observer);

    if (isFunction(errorCb)) {
      this._auth.emitter.once(this._publicEvents.error, errorCb);
    }

    if (isFunction(successCb)) {
      this._auth.emitter.once(this._publicEvents.success, successCb);
    }

    return this;
  }
github invertase / react-native-firebase / packages / database / lib / DatabaseQuery.js View on Github external
on(eventType, callback, cancelCallbackOrContext, context) {
    if (!eventTypes.includes(eventType)) {
      throw new Error(
        `firebase.database().ref().on(*) 'eventType' must be one of ${eventTypes.join(', ')}.`,
      );
    }

    if (!isFunction(callback)) {
      throw new Error("firebase.database().ref().on(_, *) 'callback' must be a function.");
    }

    if (
      !isUndefined(cancelCallbackOrContext) &&
      (!isFunction(cancelCallbackOrContext) && !isObject(cancelCallbackOrContext))
    ) {
      throw new Error(
        "firebase.database().ref().on(_, _, *) 'cancelCallbackOrContext' must be a function or object.",
      );
    }

    if (!isUndefined(context) && !isObject(context)) {
      throw new Error("firebase.database().ref().on(_, _, _, *) 'context' must be an object.");
    }
github invertase / react-native-firebase / packages / database / lib / DatabaseQuery.js View on Github external
once(eventType, successCallBack, failureCallbackOrContext, context) {
    if (!eventTypes.includes(eventType)) {
      throw new Error(
        `firebase.database().ref().once(*) 'eventType' must be one of ${eventTypes.join(', ')}.`,
      );
    }

    if (!isUndefined(successCallBack) && !isFunction(successCallBack)) {
      throw new Error("firebase.database().ref().once(_, *) 'successCallBack' must be a function.");
    }

    if (
      !isUndefined(failureCallbackOrContext) &&
      (!isObject(failureCallbackOrContext) && !isFunction(failureCallbackOrContext))
    ) {
      throw new Error(
        "firebase.database().ref().once(_, _, *) 'failureCallbackOrContext' must be a function or context.",
      );
    }

    if (!isUndefined(context) && !isObject(context)) {
      throw new Error(
        "firebase.database().ref().once(_, _, _, *) 'context' must be a context object.",
      );
    }

    const modifiers = this._modifiers.toArray();

    return this._database.native
      .once(this.path, modifiers, eventType)
github invertase / react-native-firebase / packages / admob / lib / ads / RewardedAd.js View on Github external
onAdEvent(handler) {
    if (!isFunction(handler)) {
      throw new Error("firebase.admob() RewardedAd.onAdEvent(*) 'handler' expected a function.");
    }

    return this._setAdEventHandler(handler);
  }
github invertase / react-native-firebase / packages / indexing / lib / index.js View on Github external
onOpenURL(listener) {
    if (!isFunction(listener)) {
      throw new Error("firebase.indexing().onOpenURL(*) 'listener' must be a function.");
    }

    Linking.addEventListener('url', ({ url }) => listener(url));
    return () => Linking.removeEventListener('url', listener);
  }
}
github invertase / react-native-firebase / packages / admob / lib / ads / InterstitialAd.js View on Github external
onAdEvent(handler) {
    if (!isFunction(handler)) {
      throw new Error(
        "firebase.admob() InterstitialAd.onAdEvent(*) 'handler' expected a function.",
      );
    }

    return this._setAdEventHandler(handler);
  }

@react-native-firebase/app

A well tested, feature rich Firebase implementation for React Native, supporting iOS & Android. Individual module support for Admob, Analytics, Auth, Crash Reporting, Cloud Firestore, Database, Dynamic Links, Functions, Messaging (FCM), Remote Config, Sto

Apache-2.0
Latest version published 1 day ago

Package Health Score

98 / 100
Full package analysis