Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

只允许创建单个实例无法应对 Vue 多组件同时引用的情况 #660

Closed
qwqcode opened this issue Dec 16, 2023 · 0 comments
Closed
Labels
bug Something isn't working enhancement New feature or request

Comments

@qwqcode
Copy link
Member

qwqcode commented Dec 16, 2023

v2.7.0 已发布。

重大变更

'artalk' npm 包导出的以下顶层函数已被弃用:Artalk.updateArtalk.reloadArtalk.destroy。这些方法现在需要在由 Artalk.initnew Artalk 创建的实例上调用。请改用实例级别的方法调用,比如 artalkInstance.update。更多信息请参考文档

更新是为了实现同时创建多个实例,以适应Vue组件同时被引用于不同页面的情况。最初,只允许一个单独的实例以减少内存泄漏的问题。然而,这对于涉及通过“keep-alive”缓存多个组件实例的情况来说有所限制。为了更好地满足复杂的单页面应用程序需求,选择允许创建多个独立的实例。在Vue组件释放时,为避免内存泄漏,请记得手动调用artalk.destroy方法。


v2.7.0 had been released.

BREAKING CHANGE

The following top-level functions exported by the 'artalk' npm package have been deprecated: Artalk.update, Artalk.reload, and Artalk.destroy. These methods now require invocation on an instance created by either Artalk.init or new Artalk. Please utilize instance-level methods instead, such as artalkInstance.update. For more information, refer to the documentation.

The update was implemented to enable the concurrent creation of multiple instances, adapting to situations where Vue components are simultaneously referenced across various pages. Initially, only a singular instance was permitted to mitigate memory leak concerns. However, this proved limiting for scenarios involving the caching of multiple component instances through 'keep-alive.' To better suit intricate SPA application needs, the choice was made to permit the creation of multiple independent instances. It's crucial to remember to manually invoke the artalk.destroy method when releasing components to avoid memory leaks.


#373 (comment)

#658 (comment)

vuepress-theme-hope/vuepress-theme-hope#3592

vuepress-theme-hope/vuepress-theme-hope#3550

vuepress-theme-hope/vuepress-theme-hope#3592 (comment)

#608

@qwqcode qwqcode added the enhancement New feature or request label Dec 16, 2023
qwqcode added a commit that referenced this issue Dec 16, 2023
BREAKING CHANGE: The following top-level methods, such as `Artalk.update`, `Artalk.reload`, and `Artalk.destroy`, have been removed. These methods now require invocation on an instance created by Artalk.init or new Artalk. This change was made to support creating multiple instances simultaneously, adapting to use cases where Vue components are referenced in different pages at the same time. Previously, only a single instance was allowed to prevent memory leak issues, which was insufficient for scenarios like caching multiple component instances using keep-alive. To better accommodate more complex SPA application scenarios, the decision was made to allow the creation of multiple independent instances. Remember to manually invoke the `artalk.destroy` method when releasing components to prevent memory leaks. (#660)
@qwqcode qwqcode changed the title 只允许创建单个实例的 Artalk.init 函数无法应对 Vue 多组件同时引用的情况 只允许创建单个实例无法应对 Vue 多组件同时引用的情况 Dec 17, 2023
@qwqcode qwqcode added the bug Something isn't working label Dec 17, 2023
qwqcode added a commit that referenced this issue Dec 17, 2023
BREAKING CHANGE: The following top-level functions exported by the 'artalk' npm package have been deprecated: `Artalk.update`, `Artalk.reload`, and `Artalk.destroy`. These methods now require invocation on an instance created by either `Artalk.init` or `new Artalk`. Please utilize instance-level methods instead, such as `artalkInstance.update`. For more information, refer to  [the documentation](https://artalk.js.org/guide/frontend/import-framework.html). The update was implemented to enable the concurrent creation of multiple instances, adapting to situations where Vue components are simultaneously referenced across various pages. Initially, only a singular instance was permitted to mitigate memory leak concerns. However, this proved limiting for scenarios involving the caching of multiple component instances through 'keep-alive.' To better suit intricate SPA application needs, the choice was made to permit the creation of multiple independent instances. It's crucial to remember to manually invoke the `artalk.destroy` method when releasing components to avoid memory leaks (Issue #660).
@qwqcode qwqcode closed this as completed Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant