Git Product home page Git Product logo

falcor-expand-cache's Introduction

Falcor-Expand-Cache

falcor-expand-cache is a utility for generating "plain JS like" objects that represent the internal cache of a falcor model. These objects are lazy, immutable, and only represent the cache from when it was created.

Installation

To install:

npm install --save falcor-expand-cache

Usage

import expandCache from 'falcor-expand-cache';

const cache = expandedCache(falcor.getCache());

console.log(cache.users[0].company.name) // => Pied Piper

Why?

This was built to help connect falcor to other applications / libraries that require state to be immediately available rather than through a callback or promise. Currently is it used in redux-falcor.

Licence

MIT

falcor-expand-cache's People

Contributors

ekosz avatar

Stargazers

Omar Hafez avatar Dan Train avatar Ken Enda avatar Brad Pillow avatar Cymen Vig avatar

Watchers

Vincent Fretin avatar (◕ᴥ◕) avatar

falcor-expand-cache's Issues

Circular Dependency Issue When Not Returning an Atom

I'm still new to Falcor (but i guess everyone is currently) so maybe this is a standard practice that I'm not aware of currently but the issue I noticed was when returning a JSON Graph object from my value server I was just using pathValue to return {path: ['users',0,'name'], value: 'David'} but when using expandCache on my falcor.getCache() I was unable to retrieve the users name it was only returning an object that contains a get function for each letter in the value of the response, But if I viewed the cache of my Falcor model I could see the name of my user.

When looking at index.js:17 I noticed only ref, atom, and error types are supported. After returning to my server code and updating the response to use atom everything started working like a charm.

Not sure what steps to recommend to help others with this problem in the future but considering the Netflix documentation doesn't specify you need to use atom when returning a response maybe we should update the documentation to explain the need for atom or if possibly maybe we can update the expandChild function to support $type not being specified?

I'm happy to submit a PR to help resolve this issue

Falcor v0.1.15 causes stack overflow

Hi @ekosz. Thanks for this great little library. I've been using it to integrate falcor with cerebral. I took a cue from your falcor-redux library and implemented a diff and patch strategy with falcor's onChange hook. Basically whenever falcor's cache changes, I diff falcor.getCache with cerebral's single state tree and apply the changes. It's been working surprisingly well.

Unfortunately, when I upgraded to the latest falcor v0.1.15, I noticed there are a bunch of new refs in the falcor cache and I've been getting maximum call size reached when falcor-expand-cache is called.

screen shot 2015-12-29 at 10 08 25 am

screen shot 2015-12-29 at 10 09 30 am

Looks like the errors starts at index.js on line 31.

Have you run into any problems? If you're unable to reproduce, I'd be happy to create a sample app. Again, thanks for your work here, I hope there's a way forward!

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.