mcollina / async-cache-dedupe

Async cache with dedupe support
MIT License
640 stars 40 forks source link

Removing the need of CachedFunctions in Typescript #67

Closed thelinuxlich closed 1 year ago

thelinuxlich commented 1 year ago

I think it can be done if cache.define return the cache instance instead of void. If you are okay with it, I can prepare a PR.

mcollina commented 1 year ago

Would returning a Function be enough? I think it would lead to a better API.

thelinuxlich commented 1 year ago

What do you mean? I was thinking of this:


let cache = cache.define(...).define(...)

cache.fetchSomething() // this won't error in TS because we will add a type to the return of define which always merges the current Cache with the new function definition 
thelinuxlich commented 1 year ago

Any thoughts on this?

thelinuxlich commented 1 year ago

bumping because it would be a simple change

mcollina commented 1 year ago

That would work.

I was thinking more of


let fecthSomething = cache.define(...)

fetchSomething()
thelinuxlich commented 1 year ago

So you mean cache.define returning the newly created function instead of the cache container?

mcollina commented 1 year ago

Both are fine, send a PR!

thelinuxlich commented 1 year ago

70