Vaibhav Jaiswal
01/08/2024, 3:29 PM- home component
---- news component
- filter component
I want to use the news component in filter, how can i do it?
News component is a part of the navigation created in home
i want to use the same instance in filter newsArkadii Ivanov
01/08/2024, 3:39 PMArkadii Ivanov
01/08/2024, 3:40 PMVaibhav Jaiswal
01/08/2024, 3:41 PMVaibhav Jaiswal
01/08/2024, 3:43 PMHomeComponent.newsComponent
Is this the correct approach?Vaibhav Jaiswal
01/08/2024, 3:44 PMArkadii Ivanov
01/08/2024, 3:52 PMAfter creating NewsComponent. Saving it in a lateinit var inside the CompanionObject of HomeComponentI strongly advice against this approach. With Decompose we can leverage DI (i.e. passing objects via constructors). It looks like you can pass a callback to Filter component, and once new filters are confirmed and the screen is closed you can send an event to News to apply the new filters.
Vaibhav Jaiswal
01/08/2024, 3:58 PMArkadii Ivanov
01/08/2024, 4:11 PMVaibhav Jaiswal
01/08/2024, 4:15 PMVaibhav Jaiswal
01/08/2024, 4:15 PMVaibhav Jaiswal
01/08/2024, 4:16 PMVaibhav Jaiswal
01/08/2024, 4:18 PMNewsComponent
was not required, but it did not work
https://kotlinlang.slack.com/archives/C03H3N51SKT/p1704275845221209?thread_ts=1704275845.221209&cid=C03H3N51SKTArkadii Ivanov
01/08/2024, 5:00 PMArkadii Ivanov
01/08/2024, 5:03 PMVaibhav Jaiswal
01/08/2024, 5:45 PMFilterComponent(onSelected = {newsComponent.select(...) })
I'd need reference to the HomeComponent/NewsComponent
in RootComponentArkadii Ivanov
01/08/2024, 5:51 PMI'd need reference to theThis looks correct, since RootComponent is the hosting component for both.in RootComponentHomeComponent/NewsComponent