-
-
Save kepta/a9589542792a9d868381169624d69c22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var user = { | |
name: "Kushan Joshi" | |
} | |
var websites = ['Facebook', 'Github', 'Twitter', 'Dev.to', 'Medium']; | |
var memberOf = (user) => websites.filter(website => isUser(user)); | |
// either save the websites a user is part of | |
user.memberOf = memberOf(user); | |
cachedMemberOf = weakCache(memberOf); // avoid recomputing everytime | |
// or derive it everytime you need it | |
console.log(cachedMemberOf(user)); | |
render(cachedMemberOf(user)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment