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

fix: Connect component supports to unsubscribe event by pass the callback #635

Merged
merged 8 commits into from
Jan 20, 2022

Conversation

wewoor
Copy link
Collaborator

@wewoor wewoor commented Jan 19, 2022

Description

修复 connect Service 多次后,组件销毁后,导致事件无效的问题

Fixes #596

Changes

  • EventEmitter 支持通过事件 namecallback 函数引用取消订阅
  • connect HOC 组件,按 callback 取消事件订阅

How Has This Been Tested?

  • 增加 connect 组件测试用例
  • 增加 EventEmitter 测试用例
  • 在 Panel 增加 connect 的测试场景

@wewoor wewoor added this to the Next Version milestone Jan 19, 2022
@wewoor wewoor added the bug Something isn't working label Jan 19, 2022
@wewoor wewoor self-assigned this Jan 19, 2022
@codecov
Copy link

codecov bot commented Jan 19, 2022

Codecov Report

Merging #635 (a0f673a) into main (d45a807) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #635      +/-   ##
==========================================
+ Coverage   89.02%   89.03%   +0.01%     
==========================================
  Files         184      184              
  Lines        5412     5418       +6     
  Branches     1222     1224       +2     
==========================================
+ Hits         4818     4824       +6     
  Misses        586      586              
  Partials        8        8              
Impacted Files Coverage Δ
src/common/event/eventBus.ts 100.00% <100.00%> (ø)
src/common/event/eventEmitter.ts 100.00% <100.00%> (ø)
src/react/component.ts 100.00% <100.00%> (ø)
src/react/connector.tsx 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d45a807...a0f673a. Read the comment docs.

@wewoor wewoor requested a review from kiwiwong January 19, 2022 12:58
src/react/component.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@kiwiwong kiwiwong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Collaborator

@mortalYoung mortalYoung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@wewoor wewoor merged commit bde0274 into main Jan 20, 2022
@wewoor wewoor deleted the fix/connect branch January 20, 2022 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Connector HOC will unsubscribe all listeners in unmount lifecycle
3 participants