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(template-controller): ability to have a container per factory #1924

Merged
merged 3 commits into from
Mar 14, 2024

Conversation

bigopon
Copy link
Member

@bigopon bigopon commented Mar 13, 2024

📖 Description

Currently template controllers reuse the container from their owning renderer (custom element), as an optimization, also a requirement since they need to retrieve the resources information from there. This works well for all built in template controllers as they don't need to do anything special with their view factories.
Though, for application custom controller, sometimes it's more desirable to have separate container for dynamic DI work.

This PR adds a new option containerStrategy for custom attribute definition to enable this. The acceptable values are reuse and new, and the default is reuse, which is the existing behavior.
image

🎫 Issues

Resolves #1923

Thanks @mxjp

Copy link

codecov bot commented Mar 13, 2024

Codecov Report

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

Project coverage is 88.56%. Comparing base (32f00ed) to head (cce8439).
Report is 5 commits behind head on master.

Files Patch % Lines
packages/kernel/src/di.ts 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1924      +/-   ##
==========================================
+ Coverage   88.47%   88.56%   +0.08%     
==========================================
  Files         260      262       +2     
  Lines       22843    22876      +33     
  Branches     5258     5283      +25     
==========================================
+ Hits        20211    20260      +49     
+ Misses       2632     2616      -16     

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

Copy link
Contributor

@Sayan751 Sayan751 left a comment

Choose a reason for hiding this comment

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

Thanks @bigopon! Can you please add a test case of nesting?

<div example.bind="1">
  <my-ce /><!-- value of injected IExample is 1 in my-ce -->
  <div example.bind="2">
   <!-- value of injected IExample is 2 in my-ces -->
    <my-ce />
    <my-ce />
  </div>
  <my-ce /><!-- value of injected IExample is 1 in my-ce -->
</div>

@bigopon bigopon merged commit 6727b56 into master Mar 14, 2024
28 checks passed
@bigopon bigopon deleted the feat/tc-container-strategy branch March 14, 2024 11:11
AureliaEffect pushed a commit that referenced this pull request Mar 15, 2024
2.0.0-beta.13 (2024-03-15)

**BREAKING CHANGE:**

* **event:** no longer call prevent default by default (#1926) ([f71e9e7](f71e9e7))
* **exports:** no longer re-export fetch client package (#1926) ([f71e9e7](f71e9e7))

**Features:**

* **process-content:** ability to add template information to a data object (#1925) ([2a4c436](2a4c436))
* **template-controller:** ability to have a container per factory (#1924) ([6727b56](6727b56))
* **convention:** add import as support (#1920) ([7a15551](7a15551))
* **resources:** api to register resources with alias key ([7a15551](7a15551))
* **dev:** better DI error messages for instantiation (#1917) ([2fca6ea](2fca6ea))

**Bug Fixes:**

* **router-lite:** dont register config ([f71e9e7](f71e9e7))
* **di:** cache factory on singleton resolution ([dc22fb7](dc22fb7))

**Refactorings:**

* **router:** (DEV) dont swallow instantiation error details ([deee8e6](deee8e6))
* **compiler:** remove special treatment for au slot ([2a4c436](2a4c436))
* **kernel:** smaller di files, assert text options, more au slot tests ([deee8e6](deee8e6))
* **runtime:** move constructor registration into controller ([7a15551](7a15551))
* **resource:** cleanup registration, APIs (#1918) ([dc22fb7](dc22fb7))
* **resources:** cleanup util fn, move to kernel package ([dc22fb7](dc22fb7))
* **resources:** move find to corresponding resource kind ([dc22fb7](dc22fb7))
* **di:** add registrable, remove unecessary infra for attr pattern ([dc22fb7](dc22fb7))
* **resource:** remove resource protocol, simplify resource metadata ([dc22fb7](dc22fb7))

**Docs:**

* **docs:** add key documentation for the repeater (#1921) ([c3d0ed3](c3d0ed3))
* **docs:** add documentation for event preventDefault breaking change (#1926) ([f71e9e7](f71e9e7))
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.

Replacing view factory containers
2 participants