New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(populate): populated items update when changed in database #69

Open
DeividasK opened this Issue Feb 21, 2017 · 20 comments

Comments

7 participants
@DeividasK

DeividasK commented Feb 21, 2017

Original data:

goals: {
  goalId1: {
    uid: 'userId',
    partner: 'userId2'
  }
}
users: {
  userId: {
    displayName: 'John Smith'
  },
  userId2: {
    displayName: 'Jim Rogers'
  }
}

Data after population:

goals: {
  goalId1: {
    uid: {
      displayName: 'John Smith'
    },
    partner: {
      displayName: 'Jim Rogers'
    }
  }
}

I have noticed that after updating the original users.userId.displayName to Batman, the populated item did not update, i.e. goals.goalId1.uid.displayName remained John Smith. I think this is a good default behaviour, but it took me sometime to figure this one out. Maybe this should be mentioned somewhere in the docs?

@prescottprue

This comment has been minimized.

Show comment
Hide comment
@prescottprue

prescottprue Feb 21, 2017

Owner

Correct @DeividasK, populates are only once calls. The original query is most likely on (unless you provided type: 'once'), so updates in that will trigger updates. That means that populate data (i.e. user object) doesn't update when it updates.

I will add something to the docs to outline this, but it brings up the point that it might be nice to turn on this capability. It wouldn't be the default, as you mentioned, since that could potentially cause a huge amount of listeners to be set.

Owner

prescottprue commented Feb 21, 2017

Correct @DeividasK, populates are only once calls. The original query is most likely on (unless you provided type: 'once'), so updates in that will trigger updates. That means that populate data (i.e. user object) doesn't update when it updates.

I will add something to the docs to outline this, but it brings up the point that it might be nice to turn on this capability. It wouldn't be the default, as you mentioned, since that could potentially cause a huge amount of listeners to be set.

@prescottprue prescottprue self-assigned this Feb 22, 2017

@DeividasK

This comment has been minimized.

Show comment
Hide comment
@DeividasK

DeividasK Feb 22, 2017

@prescottprue being able to turn this sounds like a great possible enhancement :)

DeividasK commented Feb 22, 2017

@prescottprue being able to turn this sounds like a great possible enhancement :)

@prescottprue prescottprue changed the title from Populated items are not updated when they are changed in the database. to Populated items update when they are change in the database Feb 22, 2017

@prescottprue prescottprue changed the title from Populated items update when they are change in the database to Populated items update when they are changed in the database Feb 22, 2017

@prescottprue prescottprue changed the title from Populated items update when they are changed in the database to Populated items update when changed in the database Feb 22, 2017

@prescottprue prescottprue changed the title from Populated items update when changed in the database to Populated items update when changed in database Feb 22, 2017

@prescottprue

This comment has been minimized.

Show comment
Hide comment
@prescottprue

prescottprue Feb 25, 2017

Owner

This has been added to the roadmap for v1.4.0.

Owner

prescottprue commented Feb 25, 2017

This has been added to the roadmap for v1.4.0.

@marekolszewski

This comment has been minimized.

Show comment
Hide comment
@marekolszewski

marekolszewski Apr 12, 2017

While we wait for v1.4.0, is there a way to explicitly reload a populated item (or any other data loaded without binding)?

marekolszewski commented Apr 12, 2017

While we wait for v1.4.0, is there a way to explicitly reload a populated item (or any other data loaded without binding)?

@prescottprue

This comment has been minimized.

Show comment
Hide comment
@prescottprue

prescottprue Apr 12, 2017

Owner

@marekolszewski Not currently.

Also, the roadmap is actually going to be updated to reflect that this will not be supported until an even later version (as v1.4.0 ended up being quite large with react-native bugs/features). Will continue to update this issue thread with relevant info.

Owner

prescottprue commented Apr 12, 2017

@marekolszewski Not currently.

Also, the roadmap is actually going to be updated to reflect that this will not be supported until an even later version (as v1.4.0 ended up being quite large with react-native bugs/features). Will continue to update this issue thread with relevant info.

@prescottprue

This comment has been minimized.

Show comment
Hide comment
@prescottprue

prescottprue May 5, 2017

Owner

Getting more and more users asking for this feature. Will hopefully be the big feature of v1.5.0.

Owner

prescottprue commented May 5, 2017

Getting more and more users asking for this feature. Will hopefully be the big feature of v1.5.0.

@projoneftw

This comment has been minimized.

Show comment
Hide comment
@projoneftw

projoneftw Jun 24, 2017

Is this gonna be part of 2.0 or..? :)

projoneftw commented Jun 24, 2017

Is this gonna be part of 2.0 or..? :)

@prescottprue

This comment has been minimized.

Show comment
Hide comment
@prescottprue

prescottprue Jun 24, 2017

Owner

@projoneftw That is most likely going to be the plan. I will be reviewing and updating the roadmap this weekend to reflect recent v2 changes (as well as in which versions features such as this one will land).

Owner

prescottprue commented Jun 24, 2017

@projoneftw That is most likely going to be the plan. I will be reviewing and updating the roadmap this weekend to reflect recent v2 changes (as well as in which versions features such as this one will land).

@projoneftw

This comment has been minimized.

Show comment
Hide comment
@projoneftw

projoneftw commented Jun 25, 2017

@prescottprue I'm new to Firebase, but I think it's just changing the once at https://github.com/prescottprue/react-redux-firebase/blob/master/src/utils/populate.js#L84, right?

@prescottprue

This comment has been minimized.

Show comment
Hide comment
@prescottprue

prescottprue Jun 26, 2017

Owner

@projoneftw It is not necessarily just that because a listener is created for each child (part of why it is a callback for '.on('value' listeners and not a promise). Those listeners will need to be tracked and shut off when relevant.

It shouldn't be too "difficult" to do with respect to code, it is more so that there is the possibility for it to use tons of resources done with huge data sets. I will want to include a section in the docs explaining how it could potentially impact an application.

This should definitely make it into v2 though, at least as an option.

Owner

prescottprue commented Jun 26, 2017

@projoneftw It is not necessarily just that because a listener is created for each child (part of why it is a callback for '.on('value' listeners and not a promise). Those listeners will need to be tracked and shut off when relevant.

It shouldn't be too "difficult" to do with respect to code, it is more so that there is the possibility for it to use tons of resources done with huge data sets. I will want to include a section in the docs explaining how it could potentially impact an application.

This should definitely make it into v2 though, at least as an option.

@prescottprue prescottprue changed the title from Populated items update when changed in database to feat(populate): populated items update when changed in database Jul 4, 2017

@prescottprue prescottprue added this to the v2.0.0 milestone Aug 30, 2017

@raghavendracs

This comment has been minimized.

Show comment
Hide comment
@raghavendracs

raghavendracs Oct 3, 2017

@prescottprue wanted to check if there is any update on this? Is it still on track for 2.0?

Also is there any way for force a populate?

raghavendracs commented Oct 3, 2017

@prescottprue wanted to check if there is any update on this? Is it still on track for 2.0?

Also is there any way for force a populate?

@prescottprue

This comment has been minimized.

Show comment
Hide comment
@prescottprue

prescottprue Oct 3, 2017

Owner

@raghavendracs Yes, this is still planned for v2.

Not sure what you mean by "force a populate".

Owner

prescottprue commented Oct 3, 2017

@raghavendracs Yes, this is still planned for v2.

Not sure what you mean by "force a populate".

@raghavendracs

This comment has been minimized.

Show comment
Hide comment
@raghavendracs

raghavendracs Oct 3, 2017

Ok thanks.

At the time of loading a component there might be a set of keys which have been populated. Due to actions in the application I am firing some firebase cloud functions which do one of two possible things

  1. Add some keys and associated data
  2. Change data that was populated earlier during loading.

While I know that data has changed in firebase is it also possible for me have react-redux-firebase trigger an update of the Firebase state?

So in my understanding there would probably be no listeners but front end trigger a repopulate.

raghavendracs commented Oct 3, 2017

Ok thanks.

At the time of loading a component there might be a set of keys which have been populated. Due to actions in the application I am firing some firebase cloud functions which do one of two possible things

  1. Add some keys and associated data
  2. Change data that was populated earlier during loading.

While I know that data has changed in firebase is it also possible for me have react-redux-firebase trigger an update of the Firebase state?

So in my understanding there would probably be no listeners but front end trigger a repopulate.

@prescottprue

This comment has been minimized.

Show comment
Hide comment
@prescottprue

prescottprue Oct 3, 2017

Owner

@raghavendracs No there isn't. That is in essence what a listener would be doing.

You could create your own listener, but guessing that it is a unique path of some kind.

There is some people that have been asking for this in person as well, so it is very well known that this feature is needed.

Owner

prescottprue commented Oct 3, 2017

@raghavendracs No there isn't. That is in essence what a listener would be doing.

You could create your own listener, but guessing that it is a unique path of some kind.

There is some people that have been asking for this in person as well, so it is very well known that this feature is needed.

@raghavendracs

This comment has been minimized.

Show comment
Hide comment
@raghavendracs

raghavendracs Oct 3, 2017

Ok thanks. Will wait for the feature in v2.0

Was only checking in the hope that a complete refresh of the Firebase state on request (without differentiating between keys which have changed and ones that haven't) might have been possible.

raghavendracs commented Oct 3, 2017

Ok thanks. Will wait for the feature in v2.0

Was only checking in the hope that a complete refresh of the Firebase state on request (without differentiating between keys which have changed and ones that haven't) might have been possible.

@prescottprue prescottprue added this to To Do in v2.0.0 Oct 18, 2017

@Jonovono

This comment has been minimized.

Show comment
Hide comment
@Jonovono

Jonovono Dec 5, 2017

Wondering if this in in yet? Would be great to use!

Jonovono commented Dec 5, 2017

Wondering if this in in yet? Would be great to use!

@prescottprue

This comment has been minimized.

Show comment
Hide comment
@prescottprue

prescottprue Dec 10, 2017

Owner

@Jonovono This is not in yet. The difficultly is around making sure we correctly track listeners that are created.

When using once queries are not left open, making tracking not too difficult. Open queries are a little more complex.

Really hoping to get the time to get this in, but not sure of a timeline. Open to PRs if anyone has the time.

Owner

prescottprue commented Dec 10, 2017

@Jonovono This is not in yet. The difficultly is around making sure we correctly track listeners that are created.

When using once queries are not left open, making tracking not too difficult. Open queries are a little more complex.

Really hoping to get the time to get this in, but not sure of a timeline. Open to PRs if anyone has the time.

@prescottprue prescottprue removed this from To Do in v2.0.0 Dec 22, 2017

@prescottprue prescottprue added this to To Do in Future Versions Dec 22, 2017

@prescottprue prescottprue removed this from the v2.0.0 milestone Dec 30, 2017

@multimulti

This comment has been minimized.

Show comment
Hide comment
@multimulti

multimulti Aug 9, 2018

I'm just wondering about the state of this functionality. Is this still planned or even already solved in some way?

multimulti commented Aug 9, 2018

I'm just wondering about the state of this functionality. Is this still planned or even already solved in some way?

@prescottprue

This comment has been minimized.

Show comment
Hide comment
@prescottprue

prescottprue Aug 10, 2018

Owner

@multimulti It is not currently supported through populate, but you can do multiple levels of firebaseConnect and connect like so:

import { get } from 'lodash'

compose(
  firebaseConnect(() => [{ path: 'AC' }]),
  connect((state) => ({
    first: get(state, 'firebase.data.AC')
  }),
  firebaseConnect((props) => {
    // Only attach listener if value from first exists
   const valueFromFirst = get(props, 'first.someValue')
    if (valueFromFirst) {
      return [{ path: `BD/${valueFromFirst}` }] // you can use 
    }
  }),
  connect((state, props) => ({
    second: get(state, `firebase.data.BD.${props.valueFromFirst}`)
  })
)

Will post here when there are any updates on this being worked on. Always open to PRs if anyone gets to it.

Owner

prescottprue commented Aug 10, 2018

@multimulti It is not currently supported through populate, but you can do multiple levels of firebaseConnect and connect like so:

import { get } from 'lodash'

compose(
  firebaseConnect(() => [{ path: 'AC' }]),
  connect((state) => ({
    first: get(state, 'firebase.data.AC')
  }),
  firebaseConnect((props) => {
    // Only attach listener if value from first exists
   const valueFromFirst = get(props, 'first.someValue')
    if (valueFromFirst) {
      return [{ path: `BD/${valueFromFirst}` }] // you can use 
    }
  }),
  connect((state, props) => ({
    second: get(state, `firebase.data.BD.${props.valueFromFirst}`)
  })
)

Will post here when there are any updates on this being worked on. Always open to PRs if anyone gets to it.

@multimulti

This comment has been minimized.

Show comment
Hide comment
@multimulti

multimulti Aug 10, 2018

Thanks a lot!

multimulti commented Aug 10, 2018

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment