Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Add destroy method #106

Merged
merged 7 commits into from
May 18, 2022
Merged

Add destroy method #106

merged 7 commits into from
May 18, 2022

Conversation

rekmarks
Copy link
Member

@rekmarks rekmarks commented May 18, 2022

Supersedes #98

Adds a new method JsonRpcEngine.destroy(), based on this hack in the MetaMask extension: https://github.com/MetaMask/metamask-extension/blob/851fce9a3b155265c3eac3efe82474a0181de99e/app/scripts/metamask-controller.js#L2785

The JsonRpcMiddleware type is altered to permit a destroy property. Calling JsonRpcEngine.destroy() clears the internal middleware array, calls the destroy() method of every middleware with such an own or inherited property, and renders the engine instance unusable.

Kudos to @daoauth for the original implementation.

@rekmarks rekmarks requested a review from a team as a code owner May 18, 2022 07:56
mcmire
mcmire previously approved these changes May 18, 2022
Copy link

@mcmire mcmire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two nits, but seems like a useful change regardless.

@rekmarks rekmarks changed the title Add cleanup method Add destroy method May 18, 2022
@rekmarks rekmarks requested a review from mcmire May 18, 2022 22:34
Copy link

@mcmire mcmire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@rekmarks rekmarks merged commit 9933285 into main May 18, 2022
@rekmarks rekmarks deleted the cleanup branch May 18, 2022 22:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants