-
Notifications
You must be signed in to change notification settings - Fork 33
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
How to make the differents fragments communicate together #7
Comments
I also have similar question.How state of one Fragment passed to Another Fragment with React and Redux |
You shouldn't be passing full states between fragments. Fragments should know as little as possible about other ones. For communication you use vanilla CustomEvents or some sort of an event bus |
Hi |
This is very urgent as we are planning to offer your dream work to the clients |
i have done an app using tailor with react-redux fragments (sadly i cant open source it). Heres how it works: Each of your fragment has its own store, it is not shared across other fragments. The idea of microfrontends (fragments) is for them to be as self-sufficient as possible. Let's assume you choose vanilla CustomEvents: somewhere in // add an event listener
window.addEventListener('addToCart', e => addToCart(e.detail)) // all the sent data will be in the detail property
somewhere in let sendItemInfo = new CustomEvent('addToCart', {
detail: {
id: 123
}
})
window.dispatchEvent(sendItemInfo) Above could be a reducer Remember that once tailor assembles your fragments they all share the |
So we have to emit the event from heder and capture in individual fragment?? |
Yep, whoever will need emited data can just create a event listener |
I changed the code in this repo in order to show how to communicate and react to changes on each Fragment as detailed by @shilangyu in the #11 PR =) I will probably add an example of server-side rendering with this in mind as well |
Let's say, I have created a custom event and made it communicated. Is it secure? If anyone ( Unknow user ) manually triggers a custom event from the console (Chrome debugging console / Snippets) it will spoil the application security, right? |
it depends on which kind of operations you're relying your events on IMO |
@SathishKumar140 well we are talking about front-end after all, things are exposed to the user and they can be easily intercepted. So yes it's not 'secure' however sensitive information shouldn't be passed anyways, just logic |
Please refer - zalando/tailor#142 (comment) Basically, all I need to know is there any secured way can communicate between two micro-apps. |
Hi,
I would like to know what is the best solution to make those fragments communicate with each other ?
If we think to the basic Flux problematic, let says we want that a new message in Chat Fragment display a notification into the Header fragment.
I think I would use a state management like Redux but I don't understand how to setup this with Tailor.
Because each React components are mounted independently, I don't understand how could I nested them into a Redux Provider ?
Thanks for your recommendations 😃
The text was updated successfully, but these errors were encountered: