Comments (11)
You can simply use the emit function from ComponentToolsTrait https://symfony.com/bundles/ux-live-component/current/index.html#communication-between-components-emitting-events
from ux.
Well,
without emitting a JavaScript event
If you meant "emitting a Javascript myself" @WebMamba is 100% right to say "events" are the way to communicate between instances.
If you meant "with no event beeing dispatched or passing by the front well... it's not possible. As state holders, live components are in the DOM browsers and thus they will need to pass by the Live Controller at a certain point.
Finally, if you meant "between two components that do not know anything about the other, but as a developer i in fact do", then you maybe could use classic PHP Event dispatch ?
from ux.
I talking about classic twigComponent, not live component.
Yes, its third scenario.
But how I can listen event in one component thats dispatched in other component? that is not posible in symfony, not? because listener must be self services, not twig components.
from ux.
You are right,
I'd also say personnaly that maybe they even should not do this, as component are often more "isolated context" than statefull scopes.
What is your real use case there ? Maybe we can suggest alternative solutions ?
from ux.
I want change favicon based on status from other components.
I have 2 types of component that change page status in 10 instances. so in page is 20 components. I want from some this component call FaviconComponent for change favicon on page.
This 20 instances do some calculations and result is some status o fomething. if one status is danger, i want change favicon
from ux.
You could do the opposite: all your livecomponents triggers some event when they compute/change status.
And another one listen to these events and refresh the favicon.
What do you think ?
from ux.
Yes, this is exactly what I want. But I did not use livecomponent. only normal twig component.
Now Im changed everything to livecomponent and, of corse, its working. But question from root comment is not answered. How to send event in normnal twig component.
from ux.
Twig components have no state, they are destroyed immediately after render, so they cannot "send" events to the backend, receive other ones, etc etc as no one could answer or use them.
You could use custom Event from Symfony EventDispatcher dispatched from your TwigComponent as I said, but not sure you'd fine exactly what you want there.
So, i think i do have already answered in fact. Nicely and trying to help as much as possible.
from ux.
Yes, I want use symfony EventDispatcher!
But I dont know how. How I can listen event in twig component.
I need send symfony event from one component to another, but I think this is not possible.
from ux.
A Twig component cannot receive event, so no.
from ux.
Thanks
from ux.
Related Issues (20)
- React Integration not working HOT 2
- [LiveComponent] LiveCollectionType Errors on Blank Field Submission HOT 1
- [TwigComponents] Classes not found(Pimcore) HOT 10
- [LiveComponent][Bug] Header not recognize if chartset is added HOT 2
- Twig Component with Stimulus Attributes HOT 4
- [Twig Component] BC break in latest release (2.18)? HOT 6
- Prevent updates to package.json HOT 9
- [LiveComponent] automatically refresh component HOT 1
- [LiveComponent] Emitting Event to specific instance HOT 7
- [Live Component][Dependent Form] Embedding dependent form HOT 2
- [TwigComponent] `exposePublicProps` + Unitialized public property = Exception HOT 4
- [TwigComponents] [Question] Render component using dynamically passed name HOT 7
- [TwigComponent][LiveComponent] Live attributes forwarding with attribute nesting HOT 7
- please delete
- Twig-components see different _context when rendered with <twig:Test></twig:Test> instead of <twig:Test/> HOT 5
- [LiveComponent] [cropperjs] Doesnt work from pathfile HOT 5
- [TwigComponent] Passing components as Props HOT 4
- [ChartJS] Error Connecting Controller HOT 5
- [LiveComponent] property is not Stateful HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ux.