docsifyjs / docsifyjs/docsify

Add a `dispose()` method to `Docsify` to clean up the instance

Đang mở
#1,719 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
JavaScript
Star
31.5k
Fork
5.8k
Merge trung bình
9 ngày 8 giờ
Pull request đã merge (30 ngày)
2

Mô tả

## Feature request

Add a `dispose()` method so that `Docsify` can be cleaned up when no longer needed.

#### What problem does this feature solve?

This is needed for embedding Docsify (https://github.com/docsifyjs/docsify/issues/799) on sites that switch to and from a view that has a Docsify instance (maybe they have multiple Docsify instances on different pages).

People currently can not clean up the instance when they will no longer render it.

#### What does the proposed API look like?

```js
// later
window.$docsify.dispose() // or similar
```

and for people who will use the `Docsify` class directly,

```js
const docsify = new Docsify(...)

// later
docsify.dispose()
```

#### How should this be implemented in your opinion?

Add a dispose method that cleans up route change listeners, anchor link click handlers, etc.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.