Timeline for Is it OK to use Promises for Caching
Current License: CC BY-SA 3.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 6, 2023 at 4:49 | comment | added | karfau | You might want to consider some more cases: If the cached Promise has been rejected you might want to try again on the next call. I think it makes sense to wrap this into an own class to have a clearly defined behavior and not have to deal with all the edge cases all the time. Here is an example implementation (that goes some steps further): gist.github.com/karfau/bafcbf3aad9e7e7db5e447aae06fe237 | |
Nov 9, 2017 at 3:43 | comment | added | PandaWood | Right, appreciate the effort! Looks like I was returning the value of _.memoize instead of assigning a function name to it | |
Nov 9, 2017 at 1:08 | comment | added | Winston Ewert | You can't make getAll().then(console.log('done')) to work, you have to pass a function to then. | |
Nov 9, 2017 at 0:45 | comment | added | Winston Ewert |
I was missing a closing }) but after fixing that it works for me. See my pastebin here: pastebin.com/hM0JTqJG
|
|
Nov 9, 2017 at 0:42 | history | edited | Winston Ewert | CC BY-SA 3.0 |
added 16 characters in body
|
Nov 8, 2017 at 23:57 | comment | added | PandaWood | the _.memoize example doesn't work as far as my testing shows. _.memoize returns a "Function" so getAll() doesn't return a Promise, so can't be used with .then() at that point. so I don't quite see how this is meant to work. The goal is to write getAll().then(console.log('done')? Even when I do get this code to work, the promise returns immediately with 'undefined' (and I tested on code that was already working previous to adding _memoize) | |
S Jul 2, 2015 at 19:06 | history | suggested | CommunityBot | CC BY-SA 3.0 |
Added missing return
|
Jul 2, 2015 at 18:07 | review | Suggested edits | |||
S Jul 2, 2015 at 19:06 | |||||
Apr 13, 2015 at 17:29 | vote | accept | Harry Pehkonen | ||
Apr 13, 2015 at 0:56 | history | answered | Winston Ewert | CC BY-SA 3.0 |