Code Monkey home page Code Monkey logo

firedux's Introduction

🔥 🐣 firedux NPM version Build Status Firebase React

Firebase + Redux for React

📖 Read the docs!

Firedux (fiery·ducks) wraps the Firebase JavaScript API to dispatch Redux actions that optimisically & immediately read/write to an in-memory subset of your data from Firebase, then asynchronously pull & push data in the background.

Also supports some authentication methods and actions.

Works well with React.

Author

Anders D. Johnson

License

Copyright © 2015-2020 Anders D. Johnson Released under the MIT license.

firedux's People

Contributors

andersdjohnson avatar darryld avatar greenkeeperio-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

firedux's Issues

Missing url in doc for config?

I needed this property, the doc may need an update?

/**
 * Then create your Firedux instance, passing it your database reference as `ref`.
 */
const firedux = new Firedux({
  ref,
  url: 'http://somethin....' <-- missing but needed?

  // Optional:
  omit: ['$localState'] // Properties to reserve for local use and not sync with Firebase.
})

Unusable currently...

import Firedux from 'firedux' gives me: Uncaught Error: Cannot find module "firedux"

which appears to be happening because your package.json says this: "main": "dist/index.js", which doesn't actually exist. So I tried pathing directly to it at firedux/dist/src, and I get returned an empty object: firedux: Object {}

Thought maybe it was console voodoo going on so I try the next step:

const firedux = new Firedux({ url: 'https://redux-firebase.firebaseio.com/' })

and I'm getting this error: Uncaught TypeError: _src2.default is not a function

Let me know what else I can do to help you fix this as I would love to start playing with this library.

firedux.update does not update the whole state in the reducer

When calling firedux.update( path/to/item, data) it updates the data correctly in Firebase by merging it with the current data.
However, the new Redux state for firedux.data.path.to.item is created in the same way as for the set() command. That leads to a state that has only the updated value not the ones it was merged with.

Example:
Redux state before:

item: {
    title: 'Before I was named this',
    content: 'Some text as the content',
    data: '2016-01-01'
}

Redux state after calling firedux.update('item', { title: 'Some new title', checked: true }):

item: {
    title: 'Some new title',
    checked: true
}

After looking at the source code of Firedux, I suppose the reason is that the reducer function calls makeFirebaseState(action, state, action.path, action.value) for both FIREBASE_SET and FIREBASE_UPDATE.
Instead for FIREBASE_UPDATE it should call makeFirebaseState(action, state, action.path, action.snapshot.val()) (the same as FIREBASE_WATCH).

Please correct me, if I am wrong here :)

Firedux API from component

@jonathandion mentioned in #7 (comment)

What's the best way to access the Firedux API from a component (ie. outside of the file where the store was created)? Even if a new Firebase ref is created in the component, Firedux still needs the store.dispatch method. And state.firedux is just the returned data, no access to the API from there.

Thanks for your help. Nice library!

Update updeep dependency to latest version

There seems to be a problem with the currently used npm package [email protected] which requires an old peer of lodash (v3.0.0).
Using gulp with Browserify and a newer version of lodash creates a lot of "Cannot find module lodash/collection/......" errors for me. The latest version of updeep requires at least [email protected] so updating to the latest updeep version should fix that.

Installing the latest version 0.14.0 of updeep as a root dependency in my project fixed it for me.

Dynamic Firebase ref url with React router params instead of url matching

Hello,

in the TodoMVC example, the actual Firebase url is fetched by matching the session key from window.location so that every time the page loads Firedux only gets access to the current session data in Firebase.

I have a React router param groupId accessible within the App as this.props.params.groupId and want to use that in the url e.g. url: FIREBASEURL + this.props.params.groupId. It just won't work.

The problem seems to be that Firedux is created first within the Redux store when calling firedux.dispatch = store.dispatch so way before the router params are even accessible and therefore no reference to the props.

The React App is Rendered as:

<Provider store={store}>
    <Router history={history}>
    <Route path="/" component={App}>
        <IndexRoute component={Home}/>
        <Route path="group/:groupId" component={Tool}/>
        <Route path="*" component={NotFound}/>
    </Route>
    </Router>
</Provider>

Any ideas how to solve this?

Add To Combined Library

There are many libraries that provide functionality similar to this one.

Existing Libraries

Though it is nice to have different libraries with different implementations, some of the library authors were thinking of combining the best of all of them into one defacto solution. Would you be interested in joining the group of us creating this firebase-redux integration? Your solution is beautiful, and we would love your input with creating a combined library.

Here are the issues posted for the other libraries:

redux-firebase
redux-react-firebase

Thoughts?

help: login

i'm trying out the snippet provided for logging in.

handleLogin (e) {
    e.preventDefault()
    const em = this.email.value
    const pw = this.pw.value

    console.log('em', em, 'pw', pw)
    firedux.login({em, pw})
}

and i got this error:
weird thing is that it's just email, password auth but the error log said it's related to FB auth

screen shot 2016-11-21 at 8 44 22 pm

can someone provide a example repo using firedux for auth? would really appreciate it, thanks

Best practice to handle incoming watched paths

I have a watch for a path. Like the docs said, it will only resolve once (the first time). Is their a good practice to handle all new entries from that watch path?

Ex: for each new entry that get added, fire an action creator.

Please excuse my ignorance :)

Cannot find module lodash

Hey,
there is a problem with your dependencies. Lodash is there in your node_modules but when you try to compile I have a lot of 'Cannot find module' errors.

Phantom database for deployed app

Localhost dev app is talking to the right Firebase backend and displaying new data in the database tree in the dashboard/console as it should--

The deployed app however is persisting data, but not the same place as the localhost. When I use $ firebase open database or whatever, it says it's pointing to the same address, but not displaying the same database tree as the localhost, which I would expect.

So the app is functional, but I have no idea where my data is, which is a little concerning :p

Anyone else run into this?

Currently unusable

I'm getting a similar issue to the one reported in #3. I'm on "firedux": "^0.6.1", which I installed today.

The code example below errors out with a Uncaught TypeError: _firedux2.default is not a function error. _firedux2.default seems to be an empty object.

import Firedux from 'firedux'
const firedux = new Firedux({
  url: 'https://redux-firebase.firebaseio.com/',

  // Optional:
  omit: ['$localState'] // Properties to reserve for local use and not sync with Firebase.
})

Let me know if there's anything I can do to help. I'm excited to give this shot.

get data once

so i have array of keys for answers:

const arryKeys = ['answer1', 'answer2']

my data structure looks like this:

questions {
  name: 'test',
  answers: {
    answer1: true,
    answer2: true
  }
}

answers {
  answer1 {
    name: 'Yes'
  }
  answer2 {
    name: 'No'
  }
}

i tried to do this to get the actual answers value on answers

arryKeys.map((aK) => {
  firedux.get(`users/${aK}`)
})

i'm not sure what's the best way to do it, hope someone can help me, thanks

react-native support

Hi, does this library support react-native? I am seeing the following error when I try to use it in my app:

TransformError: /Users/prabhaav/Development/betaApp/node_modules/firedux/dist/src/index.js: Couldn't find preset "es2015" relative to directory "/Users/prabhaav/Development/betaApp/node_modules/firedux"

I manually installed babel: npm install babel-cli babel-preset-es2015

Then I see the following error:

screen shot 2016-08-17 at 10 13 24 am

Anybody else facing this issue?

Any larger examples?

Exploring firebase integrations for redux atm and firedux seems to having an interesting approach. Do you have any example applications you can share?

Practical react example?

Hard to picture how to use this at scale, any way to get a decent example explaining how to do so?

omit as runtime function

The omit option should accept a function, not just an array, that would accept each property as argument at runtime and return true or false to determine whether or not the key should be omitted.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.