ryansully / redux-saga-firebase

A redux saga integration for firebase.

Home Page:https://redux-saga-firebase.firebaseapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

redux-saga-firebase

CircleCI npm version Coverage Status bitHound Overall Score

A redux-saga integration for firebase.

Quick start

Install with:

yarn add redux-saga-firebase

Initialize a firebase app and instanciate redux-saga-firebase:

import firebase from 'firebase';
import ReduxSagaFirebase from 'redux-saga-firebase';

const myFirebaseApp = firebase.initializeApp({
  apiKey: "qosjdqsdkqpdqldkqdkfojqjpfk",
  authDomain: "my-app.firebaseapp.com",
  databaseURL: "https://my-app.firebaseio.com",
});

const reduxSagaFirebase = new ReduxSagaFirebase(myFirebaseApp)

You can now use reduxSagaFirebase methods in your sagas:

const authProvider = new firebase.auth.GoogleAuthProvider();

function* loginSaga() {
  try {
    const data = yield call(reduxSagaFirebase.signInWithPopup, authProvider);
    yield put(loginSuccess(data));
  }
  catch(error) {
    yield put(loginFailure(error));
  }
}

export default function* rootSaga() {
  yield [
    takeEvery(types.LOGIN.REQUEST, loginSaga);
  ];
}

Make sure your client provides a implementation of fetch, either natively or via a polyfill (whatwg-fetch is a pretty good one).

API

Index

Authentication

Database

Functions

Messaging

Storage

About

A redux saga integration for firebase.

https://redux-saga-firebase.firebaseapp.com/


Languages

Language:JavaScript 100.0%