Skip to content
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

Redux store does not get set initially when cache is primed #12

Open
RobertButera opened this issue Jan 13, 2016 · 4 comments
Open

Redux store does not get set initially when cache is primed #12

RobertButera opened this issue Jan 13, 2016 · 4 comments
Labels

Comments

@RobertButera
Copy link

Hi,

I think there us an issue with redux-falcor. Essentially if you prime your falcor cache by doing something like this:

const falcor = new Model({
  cache: {
    person: {
      name: "rob"
    }
  }
});

And then setup redux-falcor as per README, then the redux store does not get set with this data.

After staring at your implementation for a while, I realised redux-falcor relies on the falcor onChange() method being invoked (to populate the redux store). This does not appear to get invoked as part of cache priming (or if it does, gets executed before redux-falcor monkey patches the handler)

I tested the theory by starting with an empty falcor cache and then setting the person key after 3 seconds (using setTimeout). Once I did it this way, the redux store got populated with my initial falcor dataset after the setTimeout executed.

Anyway, that aside, thanks for the library. I think redux-falcor does a really nice job of integrating falcor and redux.

@ekosz
Copy link
Owner

ekosz commented Jan 15, 2016

Hey @RobertButera,

I'm in crunch mode right now at work and I'm not quite sure when I'll get a chance to look into this. But once I get some time on my hands I will try and fix for sure.

In the meantime if anyone wants to take a crack at this, I'm happy to review any and all PRs.

@RobertButera
Copy link
Author

Hey, thanks for getting back to me.

Will have a crack sometime this week if I get a chance.

Rob

@blackxored
Copy link

blackxored commented Jul 6, 2016

@RobertButera I was able to find an albeit cleaner workaround with setting the model as a proxied-to-cache data source. It does trigger there.

const model = /*... your old model data with only cache */

export default new falcor.model({ source: model.asDataSource() });

EDIT: typos 🎯

@pickhardt
Copy link
Collaborator

@blackxored I believe this would fix it. #26 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants