firebase-redux-saga
v1.0.0
Published
A redux saga integration for firebase.
Downloads
200
Readme
redux-saga-firebase
A redux-saga integration for firebase.
- Try out the example app and browse its code.
- It also works with React Native 📱! Here's a very simple example: https://github.com/n6g7/cat/tree/master/rn.
- Browse the docs at https://redux-saga-firebase.js.org/.
Quick start
Install with:
yarn add redux-saga-firebase
Initialize a firebase app and instantiate redux-saga-firebase:
import firebase from 'firebase'
import '@firebase/firestore' // 👈 If you're using firestore
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:
function* syncSaga() {
yield fork(reduxSagaFirebase.database.sync, 'todos', {
successActionCreator: syncTodos,
})
}
Make sure your client provides a implementation of fetch
, either natively or via a polyfill (whatwg-fetch
is a pretty good one).
API
Authentication
*auth.applyActionCode(code)
auth.channel()
*auth.confirmPasswordReset(code, newPassword)
*auth.createUserWithEmailAndPassword(email, password)
*auth.deleteProfile()
*auth.linkWithPopup(authProvider)
*auth.linkWithRedirect(authProvider)
*auth.sendEmailVerification(actionCodeSettings)
*auth.sendPasswordResetEmail(email, actionCodeSettings)
*auth.signInAndRetrieveDataWithCredential(credential)
*auth.signInAnonymously()
*auth.signInWithCredential(credential)
*auth.signInWithCustomToken(token)
*auth.signInWithEmailAndPassword(email, password)
*auth.signInWithPhoneNumber(phoneNumber, applicationVerifier)
*auth.signInWithPopup(authProvider)
*auth.signInWithRedirect(authProvider)
*auth.signOut()
*auth.unlink(authProvider)
*auth.updateEmail(email)
*auth.updatePassword(password)
*auth.updateProfile(profile)
Database
*database.read(path)
*database.create(path, data)
*database.update(path, data)
*database.patch(path, data)
*database.delete(path)
database.channel(path, event, buffer)
*database.sync(path, options, event)
Firestore
*firestore.addDocument(collectionRef, data)
firestore.channel(pathOrRef, type, buffer)
*firestore.deleteDocument(documentRef)
*firestore.getCollection(collectionRef)
*firestore.getDocument(docRef)
*firestore.setDocument(docRef, data, options)
*firestore.syncCollection(pathOrRef, options)
*firestore.syncDocument(pathOrRef, options)
*firestore.updateDocument(docRef, ...args)
Functions
Messaging
messaging.channel()
*messaging.syncMessages(options)
*messaging.syncToken(options)
messaging.tokenRefreshChannel()
Storage
storage.uploadFile(path, file, metadata)
storage.uploadString(path, string, format, metadata)
*storage.getDownloadURL(path)
*storage.getFileMetadata(path)
*storage.updateFileMetadata(path, newMetadata)
*storage.deleteFile(path)
Contributing
- Clone
- Link lib to example site:
yarn link
in root directoryyarn link redux-saga-firebase
inexample
directory
- Run tests:
yarn test