• Stars
    star
    574
  • Rank 77,739 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Redux bindings for Firestore

redux-firestore

Redux bindings for Firestore. Provides low-level API used in other libraries such as react-redux-firebase

NPM version NPM downloads License Code Style Build Status Code Coverage semantic-release

Gitter

Installation

npm install redux-firestore --save

This assumes you are using npm as your package manager.

If you're not, you can access the library on unpkg, download it, or point your package manager to it. Theres more on this in the Builds section below

Complementary Package

Most likely, you'll want react bindings, for that you will need react-redux-firebase. You can install the current version it by running:

npm install --save react-redux-firebase

react-redux-firebase provides withFirestore and firestoreConnect higher order components, which handle automatically calling redux-firestore internally based on component's lifecycle (i.e. mounting/un-mounting)

Overview

API Quick Start

Load data

Construct a Firestore query, attach listeners for updates and get the data from the selector.

const MyController = () => {
  // 1. construct query
  const taskQuery = {
    collection: `workspace/MySpace/tasks`,
    where:[
      ['status', '<', 1],
      ['deleted', '==', false]
    ],
    orderBy: ['createdAt', 'desc'],
    storeAs: 'tasksStarted',
  }
  
  // 2. load & attached listeners for document changes
  useFirestoreConnect([taskQuery]);

  // 3. Get results
  const tasks = useSelector(state => 
    state.firestore.cache['tasksStarted'].docs
  );
  
  // 4. Display when the data returns
  return (<ol>
    {tasks && tasks.map(({id, title}) => (
      <li key={id}>title</li>
    ))}
  </ol>);
};

Saving Data

Use redux-firestore's mutate function to queue changes to Firestore and see the optimitic results instantly in the UI.

const MyController = (task) => {
  const changeTitle = useCallback(({id, path, title}) => {
    dispatch(
      createMutate({
        doc: id, 
        collection: path, 
        title
      }))
      .catch((error) => { alert(error) });
  })
  
  return (<TaskView onSave={changeTitle} />);
};

Roadmap

  • Automatic support for documents that have a parameter and a subcollection with the same name (currently requires storeAs)
  • Support for Passing a Ref to setListener in place of queryConfig object or string

Post an issue with a feature suggestion if you have any ideas!

More Repositories

1

react-redux-firebase

Redux bindings for Firebase. Includes React Hooks and Higher Order Components.
JavaScript
2,545
star
2

generator-react-firebase

React Firebase (Redux optional) yeoman generator
JavaScript
296
star
3

cypress-firebase

Cypress plugin and custom commands for testing Firebase projects
TypeScript
255
star
4

fireadmin

Application for Managing Firebase Applications. Includes support for multiple environments and data migrations
JavaScript
240
star
5

react-google-button

Simple google button for React that follows Google's style guidelines (https://developers.google.com/identity/sign-in/web/build-button)
JavaScript
74
star
6

firebase-ci

Simplified Firebase interaction for continuous integration
JavaScript
72
star
7

redux-firebasev3

Actions/Reducer with HOC for using redux with Firebase v3
JavaScript
36
star
8

gitbook-plugin-versions-select

A gitbook plugin that provides a version dropdown. Works with multiple versions on one domain.
JavaScript
12
star
9

redux-firebase

Redux bindings for Firebase
JavaScript
7
star
10

tsheets-sdk

Javascript SDK for TSheets API
JavaScript
6
star
11

ng-reveal

Angular Directive wrapper for RevealJS presentation library.
JavaScript
6
star
12

cra-template-rrf

JavaScript
4
star
13

authrocket

Javascript library to interact with Auth Rocket service
JavaScript
3
star
14

generator-firebase-functions

Yeoman generator for creating Cloud Functions For Firebase within a Firebase project
JavaScript
3
star
15

renovate-config

My personal renovate config presets
3
star
16

functions-queue

Task Queuing for use with Cloud Functions for Firebase. Similar to firebase-queue but handles Functions events.
JavaScript
3
star
17

fireadmin-site

App for managing Firebase instances (including data migrations and analytics)
JavaScript
2
star
18

parsePush

DEPRECATED. Parse no longer exists
Go
2
star
19

devshare

JS library on which devshare.io is built and extended
JavaScript
2
star
20

redux-devshare

Redux connector for devshare library
JavaScript
2
star
21

generator-next-firebase

NextJS and Firebase project generator
JavaScript
2
star
22

tessellate

Application building/sharing API
JavaScript
2
star
23

machinepack-spotify

A machinepack to interact with the Spotify API
JavaScript
2
star
24

spanner-graphql-example

Example of React App which interacts with a Cloud Spanner instance using GraphQL (hosted on Cloud Functions)
TypeScript
2
star
25

firebase-tools-extra

Extra methods for firebase-tools which support using a service account.
TypeScript
1
star
26

AngularFireAdmin

Angular integration for FireAdmin library.
CSS
1
star
27

firething

JavaScript
1
star
28

deploy-changed-functions

TypeScript
1
star
29

portfolio

Personal website
JavaScript
1
star
30

PiOpenLighting

Open Lighting Library modified to be used on a pi that is placed in the amplifier rack that I build for my fraternity. Originally from open-lighting-24ba77cc10d1.
C++
1
star
31

Dyml

CSS
1
star
32

revealPortfolio

Portfolio sample built with RevealJS and AngularJS.
JavaScript
1
star
33

s3Upload

Go package to simplify file uploads to s3
Go
1
star
34

machinepack-jwtauth

Handle JSON Web Tokens from request headers.
JavaScript
1
star
35

devshare-cli

Command line interface for devshare
JavaScript
1
star
36

blues-mui-stack

Remix blues stack with material-ui
TypeScript
1
star
37

fireuser

User/Session management for Firebase
JavaScript
1
star
38

react-es6-basic

Basic React hello world app with ES6 and Babel.
HTML
1
star
39

new-project-tutorial

HTML
1
star
40

hypercube-server

CSS
1
star