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

Enhancement suggestion: Components as attributes in other components or tags #5668

Closed
michaelvolz opened this issue Dec 6, 2018 · 3 comments
Labels
area-blazor Includes: Blazor, Razor Components

Comments

@michaelvolz
Copy link

<MyComponent Memoize="true" ComponentProperty="@SomeValue" />

Memoize would be another component which defines the Attribute and had full access to the underlying component.

As an example it could even prohibit rendering and inject a dynamic rendertree which could be stored in a cache. I believe Taghelpers can do something similar.

More Examples:

<MyComponent Repeat="5" ComponentProperty="@SomeValue" />
<MyComponent HideWhenEnvironment="Production" ComponentProperty="@SomeValue" />
<MyComponent DisplayWhenEnvironment="Debug" ComponentProperty="@SomeValue" />
<MyComponent LazyLoad="true" ComponentProperty="@SomeValue" />
<MyComponent DataSourceWithCachingAndErrorHandling="/api/category/value/@value;bindto(ComponentProperty)" ComponentProperty="@SomeValue" />

[...]
@Andrzej-W
Copy link

It looks like a continuation of this https://github.com/aspnet/Blazor/issues/1739#issuecomment-443628737
Assuming I understand your examples correctly, components which mirror basic programming constructs (Repeat, HideWhen, etc.) are in my opinion not very useful. For caching I prefer Razor syntax:
https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/built-in/cache-tag-helper?view=aspnetcore-2.2

@michaelvolz
Copy link
Author

@Andrzej-W These are JUST examples. Replace with any functionality you like. I took the first that sprung to mind. Nothing more. btw: If you LIKE my examples or not is not very helpful at all.

And no, #1739 is not the same, but this could be a possible solution, I give you that. Everyone could implement such functionality themselves if they so choose. But that was not the reasoning behind my suggestion.

I think the Memoize example reflects the most what I had in mind. The others are just additional possibilities, nothing more.

@aspnet-hello aspnet-hello transferred this issue from dotnet/blazor Dec 17, 2018
@aspnet-hello aspnet-hello added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates area-blazor Includes: Blazor, Razor Components labels Dec 17, 2018
@mkArtakMSFT
Copy link
Member

Thanks for contacting us, @michaelvolz.
This is not something we plan to add in the near future.

@mkArtakMSFT mkArtakMSFT removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels May 9, 2019
@dotnet dotnet locked as resolved and limited conversation to collaborators Dec 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

No branches or pull requests

4 participants