I’m looking into cleaning up resources for the destroy lifecycle of my angular component. I’ve found the webViewerInstance.Core.documentViewer.dispose(); which solves some of the problems I had so that’s great. But I’ve also noticed there’s a webViewerInstance.Core.dispose(); method, with the following description:
Cleans up listeners and data from the WebViewer instance. Should be called when removing the WebViewer instance from the DOM.
That’s sound like something I need! But, despite the function being listed in the docs and in the typings file, at runtime it cannot be found. The doc example tells me to webViewerInstance.Core.dispose(), but doing that results in TypeError: this.instance.Core.dispose is not a function.
And indeed, if I inspect the object it looks like all the properties are there, except for this one method:
Unfortunately after updating to 8.1.0 this problem came back. I’ve worked on a nightly for a while, accessing dispose through the UI namespace, but in 8.1.0 that’s no longer possible. There is no longer a dispose() on UI and if I try it on Core I get the same thing as in my original post.
I’ve verified that I am indeed using 8.1.0, it’s not an old cached version or something. Immediately after installing it the compiler complained about dispose() not existing on UI. As stated originally, it doesn’t say the same for dispose() on Core but at runtime it’s just not there and it errors.
I see it in the source code. Currently there is mismatch between source code and JS doc (which is used to generate the TS typing file). For now, you can just do something like // @ts-ignore or (this.instance.UI as any).dispose().
Hi sr1, just a heads up we ended up removing that line completely. It started throwing errors, “cannot read properties of undefined (reading ‘indexOf’)” iirc.
Considering at that point it wasn’t in any documentation and the messy history of it being (re)moved all the time, we figured we’d just consider it an unsupported method. Support hasn’t explicitly said we need to use it either, and we certainly didn’t want to keep on dealing with it.
We still use the other Dispose call and for as far as we can tell that cleans up enough for a new instance to be created cleanly afterwards. I don’t know if there’s any stuff left in memory but it doesn’t seem to hinder functionality.