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

Memoize filer. #2

Closed
Serhioromano opened this issue Oct 1, 2014 · 2 comments
Closed

Memoize filer. #2

Serhioromano opened this issue Oct 1, 2014 · 2 comments

Comments

@Serhioromano
Copy link

You have code like this.

var fromCache = cache[key];
if (fromCache) {
  return fromCache;
}

I think this will not work good if service(colback) that uses it return empty array. It will trigger that service again. The fact that there is nothing in cache[key] does not mean that this was never called before.

My be I am wrong.

@m59peacemaker
Copy link
Owner

@Serhioromano oops! That was careless on my part. Empty arrays evaluate as truthy, but you are correct that I failed to handle cases where the function returns falsy values, like '' or null, etc. I have pushed the correction.

    if (cache.hasOwnProperty(key)) {
      return cache[key];
    }

@Serhioromano
Copy link
Author

Ok, good. I see ad61550.

Thank you. Good staff by the way.

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

No branches or pull requests

2 participants