memoize-one-with-dispose
A memoization function based on memoize-one
with disposing function.
Background
memoize-one
is a popular utility package for memoization. It is simple and straightforward. But sometimes, you may use it to hold resources that requires a manual release. This package enhance memoize-one
with a disposing function that would call before a new memoized object is created.
Although JavaScript automatically do garbage collection, sometimes you may be working with resources that requires an explicit stop or cancellation.
To install
Run npm install memoize-one memoize-one-with-dispose
.
This package peer-depends on
memoize-one
.
memoize-one-with-dispose
Before using Before using this package, you will need to write code like this.
; let created lastValue; const createOrGetValue = ;
memoize-one-with-dispose
After using After using this package, you can write shorter and more readable code like this.
; const createOrGetValue = ;
Contributions
Like us? Star us.
Want to make it better? File us an issue.
Don't like something you see? Submit a pull request.