s3rius
07/09/2024, 7:19 AMduplicateConfigurationsEnabled
? I'm quite interested because I have a few scenarios where I would like to be able to have the same configurations- at the moment I solve this by adding an index or a random UUID to each config.
I'm guessing Decompose will use the order of equal configurations to match it to components? Meaning if I have configs listOf(A1, A2)
(both A's being equal), it will create Child(A1, Comp1) and Child(A2, Comp2). And if I were switch them via nav.update { listOf(A2, A1) }
I would probably end up with Child(A2, Comp1) and Child(A1, Comp2)?Arkadii Ivanov
07/09/2024, 7:40 AMs3rius
07/09/2024, 11:26 AMlistOf(Home, News(original), News(related))
. So it's possible for the user to click through related articles until they end up at an article they were already at, which would be a duplicate configuration entry.
In this case, swapping of configurations would pretty much never occur.
The more relevant use-case is large lists of items. If you remember, I was asking about a list-navigation some weeks ago. Basically the equivalent of Pages
but for a lazy-column/row instead.
For my use-case, the contents of this list are provided by a (paginated) API, and there isn't a reason why the same item wouldn't be in there more than once. In fact, it's expected to happen because we interlace ads in regular intervals, and these ads would sometimes repeat.
In this case, swapping of configurations should pretty much never occur but it's harder to reason about because new pages can be loaded via pagination, and unloaded via a refresh mechanic.
The individual items of this list are pretty complex and it's very useful to have every item be represented by a Component (with lifecycle, etc), so using Decompose for that has been the right choice. It just took a little extra (unique IDs based on index position) to ensure the list doesn't blow up when a duplicate is shown.s3rius
07/09/2024, 11:33 AMduplicateConfigurationsEnabled
in the latest alpha and was curious given that it was relevant to what I was working with over the past few weeks.Arkadii Ivanov
07/09/2024, 11:37 AMpushToFront
(equivalent to FLAG_ACTIVITY_REORDER_TO_FRONT).
2. The case with ads in Pages is a very interesting one! How I would handle it: I would add a number
property to the ad configuration class, and probably write a custom navigation extension function to automatically increment the number for every new ad in the list based on the last ad in the list. This would make sure that if I ever need to remove a random ad from the list (e.g. the user clicks a Dismiss or Report button, or something similar), then their corresponding components wouldn't mess up.s3rius
07/09/2024, 11:51 AMnumber
into an implementation detail, whereas right now it's the responsibility of the hosting component to add a unique id based on some criteria.s3rius
07/09/2024, 12:03 PMArkadii Ivanov
07/09/2024, 12:05 PM