Skip to content

Conversation

hexf00
Copy link
Member

@hexf00 hexf00 commented Aug 22, 2024

Hooks naming will be standardized to the format: prefix + verb in present tense + noun.

  • beforeCreateUnit
  • afterCreateUnit
  • beforeDisposeUnit
  • afterDisposeUnit

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).

for (const callback of this.beforeUnitAddCallbacks) {
if (callback(unit) === false) {
// if not use throw error, the createUnit returns null
throw new Error('[UniverInstanceService]: cannot add unit with user callback.');
Copy link
Member Author

Choose a reason for hiding this comment

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

@wzhudev Check if this has been handled properly.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know. It is your responsibility to check if it is handled properly.

Copy link

github-actions bot commented Aug 22, 2024

View Deployment

📑 Examples 📚 Storybook
🔗 Preview link 🔗 Preview link

});

// TODO: not calling dispose() method
// unit.dispose();
Copy link
Member Author

Choose a reason for hiding this comment

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

@wzhudev The unit.dispose() function is not associated; in the future, a better and more unified mechanism is needed. Consider moving dispose to UnitModel or an intermediate layer. Use dispose for the destroy function.

Copy link
Contributor

Choose a reason for hiding this comment

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

Already clearified this with hexf00 offline.

@hexf00 hexf00 force-pushed the feat/facade-unit-hooks branch from 8a0b16c to 0e106b7 Compare August 22, 2024 14:32
@hexf00 hexf00 marked this pull request as ready for review August 22, 2024 14:34
Copy link

codecov bot commented Aug 22, 2024

Codecov Report

Attention: Patch coverage is 72.22222% with 15 lines in your changes missing coverage. Please review.

Project coverage is 27.65%. Comparing base (71857c1) to head (7423d7c).
Report is 1 commits behind head on dev.

Files Patch % Lines
packages/facade/src/apis/hooks/f-unit-hooks.ts 72.72% 9 Missing ⚠️
...ges/core/src/services/instance/instance.service.ts 45.45% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #3158      +/-   ##
==========================================
+ Coverage   27.63%   27.65%   +0.01%     
==========================================
  Files        1984     1985       +1     
  Lines      105556   105605      +49     
  Branches    22792    22795       +3     
==========================================
+ Hits        29172    29200      +28     
- Misses      76384    76405      +21     

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

@hexf00 hexf00 force-pushed the feat/facade-unit-hooks branch from 0e106b7 to 7423d7c Compare August 23, 2024 02:41
* It also manages the focused univer instance.
*/
export interface IUniverInstanceService {
/** A set of callbacks that will be called before a new unit is added. */
Copy link
Contributor

Choose a reason for hiding this comment

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

Should never expose internal properties as mutable. Instead, provide methods to do that.

// TODO: not calling dispose() method
// unit.dispose();

const _univerInstanceService = get(IUniverInstanceService);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not necessary to add an underscore before a variable. The underbar has a special usage for "not used variables".

});

// TODO: not calling dispose() method
// unit.dispose();
Copy link
Contributor

Choose a reason for hiding this comment

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

Already clearified this with hexf00 offline.

@jikkai jikkai self-requested a review as a code owner June 21, 2025 05:34
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.

2 participants