saus icon indicating copy to clipboard operation
saus copied to clipboard

Investigate whether memory usage can be reduced by not caching Promise objects

Open aleclarson opened this issue 3 years ago • 0 comments

image

My strategy would be to wrap cached promises with a new CachedPromise class.

class CachedPromise {
	constructor(promise) {
		this.promise = promise
		promise.then((result) => {
			this.result = result
			this.promise = null
		}, (error) => {
			this.error = error
			this.promise = null
		})
	}
	then() {}
	catch() {}
	finally() {}
}

aleclarson avatar Mar 15 '22 20:03 aleclarson