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

feat(facade): add lifecycle hooks for facade #2357

Merged
merged 1 commit into from
Jun 2, 2024
Merged

Conversation

Dushusir
Copy link
Member

@Dushusir Dushusir commented May 30, 2024

为什么要新增 lifecycle 钩子?
注册 canvas 扩展的 Facade API,必须在渲染完成之后才能调用,可以抛出生命周期的钩子,让用户知道已经渲染完成,再调用 canvas 扩展的API

文档待补充

Pull Request Checklist

  • Related tickets or issues have been linked in the PR description (or missing issue).
  • Naming convention is followed (do please check it especially when you created new plugins, commands and resources).
  • Unit tests have been added for the changes (if applicable).
  • Breaking changes have been documented (or no breaking changes introduced in this PR).

@Dushusir Dushusir marked this pull request as ready for review May 30, 2024 07:30
@Dushusir Dushusir requested a review from hexf00 as a code owner May 30, 2024 07:30
@univer-bot
Copy link

univer-bot bot commented May 30, 2024

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿

Origin Title: feat(facade): add lifecycle hooks for facade

Title: feat(facade): add lifecycle hooks for facade


Why add lifecycle hook?
Register the Facade API of the canvas extension, which must be called after the rendering is completed. You can throw a life cycle hook to let the user know that the rendering has been completed, and then call the canvas extension API.

Documents to be added

Pull Request Checklist

  • Related tickets or issues have been linked in the PR description (or missing issue).
  • Naming convention is followed (do please check it especially when you created new plugins , commands and resources).
  • Unit tests have been added for the changes (if applicable).
  • Breaking changes have been documented (or no breaking changes introduced in this PR).

@Dushusir Dushusir requested a review from wzhudev May 30, 2024 07:33
Copy link

codecov bot commented May 30, 2024

Codecov Report

Attention: Patch coverage is 69.23077% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 29.26%. Comparing base (e831c6c) to head (e35d308).

Files Patch % Lines
packages/facade/src/apis/f-hooks.ts 63.63% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #2357   +/-   ##
=======================================
  Coverage   29.25%   29.26%           
=======================================
  Files        1515     1516    +1     
  Lines       76698    76711   +13     
  Branches    15929    15929           
=======================================
+ Hits        22441    22449    +8     
- Misses      54257    54262    +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented May 30, 2024

View Deployment

📑 Examples 📚 Storybook
🔗 Preview link 🔗 Preview link

/**
* Get hooks
*/
getHooks() {
Copy link
Member

Choose a reason for hiding this comment

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

The name should be more specific, like getLifecycleHooks. Unless you're going to bind other types of hooks o f-hook. (And what are other possible books?)

Copy link
Member Author

Choose a reason for hiding this comment

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

I have considered this, and it is indeed worth discussing.

The current design is divided into 4 types of hooks, FHooks general hooks, FSheetHooks/FDocHooks/FSlideHooks hooks for specific document types

Although the role of hooks can be replaced by listening to Command in most scenarios, hooks are more semantic and more popular. In the future, we may refer to hansontable to add some hooks https://handsontable.com/docs/javascript-data-grid/api/hooks/
Add afterDispose, afterCopy, afterPaste... to FHooks

This brings up a management issue. Should the internal distinction of the 4 types of hooks be refined?
If it is necessary to refine, it can be divided into
FLifecycleHooks: including life cycle, dispose event
FClipboardHooks: clipboard hook
FRowHooks
FColumnHooks
FCellHooks
etc.

Which solution is better?

Copy link
Member

@wzhudev wzhudev Jun 2, 2024

Choose a reason for hiding this comment

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

OK. Let's merge all hooks in this class. Maybe it's better for new users to get what they want.

@Dushusir Dushusir requested a review from wzhudev June 1, 2024 10:49
Copy link
Member

@wzhudev wzhudev left a comment

Choose a reason for hiding this comment

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

LGTM

@wzhudev wzhudev merged commit ebb1d59 into dev Jun 2, 2024
14 checks passed
@wzhudev wzhudev deleted the feat/facade-hooks branch June 2, 2024 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants