-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Consume #39102
Consume #39102
Conversation
Thought: I considered renaming |
I think |
@ratatatKE I just think it may have communicated what is happening a bit better? The component is simply "aware" of some contextual data that was possessed by its ancestors. It's not actually consuming or receiving anything explicitly. |
I get you @taylorotwell. However if the lifetime (the duration between allocation and deallocation of memory) of the variables are staying stagnant and not increasing/changing, wouldn't it be more fit we consider a keyword like |
@taylorotwell take a look at my comments in the other PR. With this implementation, the 3rd item is going to be red. I would expect it to be blue… <x-menu color="blue">
<x-menu.item>Blue 1</x-menu.item>
<x-menu.item color="red">Red 1</x-menu.item>
<x-menu.item>What color is this?</x-menu.item>
</x-menu> |
@inxilpro Uh oh... does your implementation pass all my other tests exactly? |
@inxilpro yes please |
From an idea by @calebporzio ...
When building complex Blade components, it's hard / impossible to access data passed into the parent from children in the parent's slot.
For a concrete example of the problem (using a
x-menu
component):Usage
Notice we are passing in a "color" attribute to the parent component. Here's the parent component definition:
x-menu
Now this component has access to
$color
, but it doesn't actually need it. We need to access$color
from eachmenu-item
component:x-menu.item
Can now be done via
@consume
directive in the child... defaults are also supported if no consumable data with the given name can be found in the parent component stack...x-menu.item