Fix delegate decorator not removing function from map #75
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey! First of all, really cool library 😄
It seems like the map in the delegate decorator is acting like a permanent cache for the method to delegate. So even after the promise is resolved, the first result is being returned when calling the method with delegation again afterwards. I think this is not the expected behaviour according to the docs:
For a given input, if within the time period of the resolving of the promise of the first invocation the decorated method was invoked multiple times (with the same input) the response would be the promise that was generated by the first invocation.
This pr should fix the issue. I added a test in the spec to verify it!
As a sidenote, I would recommend you running
npm version x.x.x
instead of updating the value mannually. It changes the version both on the package and package-lock files. When I npm installed the library locally, package-lock.json was modified automatically because of this.