Metamask: Dealing the Ethereum Launteer does not work
As a policeman Metamask, you, verbatim, are the Importance of the Imperial Coat on the Ethereum blockchain. However, when it comes to the felling of these hensers, all can be difficult. In this state, we disperse, why the method ethereum.removeliser 'does not work as it was, and the predatory of some of the arrangements.
Problem:
The method ofethereum.removeliser ‘is used for the felling of the skiller of the Consultic Ethereum listener. However, in your servant, you will use JavaScript (not typescript) and ask you to use the method ethereum.removeliser 'for Metamask. To the sooty, this method does not work for not JavaScript.
Resolution:
To solve the problem, we need to find the alternative safety of the servant of the metamask. One of the possibilities is the use of the methodethereum.onoff, which allows you to include and turn off the henser. Here's the primer that you can change your code to get it:
Javascript
Const Stirler = Ethereum.on ('Event', Function (Event) {
// Abbite Logic Sobiti here
});
// Red
Ethereum.off ('Event', Function () {
Console.log ('Listening Sobyti Redeely');
});
In this primer, we use ethereum.Off
for the felling of the henchman of the workers, when this is no longer needed. Obrate that this method works only for the hensers, which do not permanently secure.
LOOD WAY:
If you need more control over the slusters or you want to kill that they are right, even the method ethereum.Of 'do . This library implies a simple safety of the editors of the Ethereum and allows you to hit them, do not go on the method
ethereum.onoff.
Conclusion:
In this state, we were glued, why the method ethereum.removeliser 'does not work for non javascript surdents and imposed alternative resolution with the method
ethereum.onoff’. Added these arrangements, you are able to strike out the Ethereum event from the Metamask slopers without any problems.
Primer Uspolzing:
Here’s a simple prime that you can use the library ethereum-refer ':
Javascript
{Ethereumoffender}
Const Stirler = New Ethereumoffender ();
Listening service.on ('Event', Function (Event) {
console.log (ecepted: $ {Event});
});
// Red
Listening.off ('Event', Function () {
Console.log ('Listening Sobyti Redeely');
});
In this one, we use the library “Ethereum-Offer” for the management of our Ethereum. We can strike out the henchman of the workpiece, do not go on the method ethereum.onoff.
Adopolitic COVES:
- Encourage that you have installed the unusual libraries, startingnpm to install ethereum-affer
or
Jarn Add Ethereum-Affer ‘.
- Immet in the view that some libraries can be overwhelmed or treated, therefore obligatory to check them over their use.
- How in any library, be the steady change of your code and impact that you are nominating its use before its realization in the production.