off
Removes a callback added with on
or once
.
Supported on:
Signature
off(type: 'nodechange', callback: (event: NodeChangeEvent) => void): void
Remarks
The callback needs to be the same object that was originally added. For example, you can do this:
Correct way to remove a callback
let fn = () => { console.log("nodechange") }
page.on("nodechange", fn)
page.off("nodechange", fn)
whereas the following won't work, because the function objects are different:
Incorrect way to remove a callback
page.on("nodechange", () => { console.log("nodechange") })
page.off("nodechange", () => { console.log("nodechange") })