feat: make dispose support disposing instance of useFactory #116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
处理 #111
处理方式:把 instance 挂在 creator 上, 形式为一个
Set
。原instanceDisposedEmitter
方法,不再以instance
为参数,而是以creator
作为参数。当 creator dispose 时,重置creator.instance
。同时解决以下问题:
useFactory
在dispose
时 instance 无法被删除class provider
为多例模式时,执行dispose
时, 实例的dispose
方法不会被调用。更新后, 多例的class provider
被dispose
时,其所有实例的dispose
方法都会被调用hasInstance
无法判别useFactory
, 更新后,useFactory
的返回值,也可以通过hasInstance
来进行判别。且多例class provider
的instance
同样可以被判别。