javascript - nodejs events is being called multiple times -
I am working on a CMS, which is hosted nodes. Here I have added some hook hooks. >
mpObj.emit ('MP3 Footer', 'Center & gt; MPTEST plugin was successfully loaded. & Lt; / center & gt;'); When I handle this event here:
mpObj.on ("MP: footer", function (str) {console.log ( Str); if (str) {httpResponse.locals.siteFooter + = str;}}); This is being executed several times in 1 page. Patterns as follows:
- If the page loads for the first time, it will be executed once.
- If the page completes the second time, then it will be executed twice.
- If the page is full of EN, it will be executed annually.
Please advise.
I do not know how your CMS works, but I think the listener is registered multiple times Used to be. mpObj.off ("MP: FOOTER"); or try adding the related function to your CMS before mpObj.on () call.
Comments
Post a Comment