Abhimanyu
05/12/2024, 4:36 PMcombine
like this,
public val screenUIData: StateFlow<MyResult<AddOrEditAccountScreenUIData>?> = combine(
flow1,
flow2,
flow3,
flow4,
flow5,
flow6,
...
) { flows ->
val data1 = flows[0] as? <DataType> ?: <DefaultValue>
val data2 = flows[1] as? <DataType> ?: <DefaultValue>
val data3 = flows[2] as? <DataType> ?: <DefaultValue>
val data4 = flows[3] as? <DataType> ?: <DefaultValue>
val data5 = flows[4] as? <DataType> ?: <DefaultValue>
val data6 = flows[5] as? <DataType> ?: <DefaultValue>
...
}
Detekt is throwing error MagicNumber
for the index usage of the flows
.
How to ignore this across the project?
Note: I don't want to completely disable the MagicNumber
lint check, I want to ignore only for this particular use case.
Can anyone please help thank you colorephemient
05/12/2024, 7:27 PMcombine(...) { (data1, data2, data3, data4, data5) ->
val data1 = data1 as? <DataType> ?: <DefaultValue>
...
Abhimanyu
05/12/2024, 7:30 PMcombine
more than 5 flows.David Rawson
05/12/2024, 9:09 PMDavid Rawson
05/12/2024, 9:10 PMephemient
05/13/2024, 5:17 AMcombine
overloads for 2 to 5 flows, whose lambdas receive multiple parameters and thus would be written
combine(flow1, flow2, flow3) { data1, data2, data3 ->
as well as combine
overloads for vararg Flow
and Iterable<Flow>
, whose lambdas receive an array. the array can be destructured immediately as I wrote above.Abhimanyu
05/13/2024, 5:28 AMcombine
has only 2 to 5 parameter overloads.ephemient
05/13/2024, 7:30 AMephemient
05/13/2024, 7:38 AMAbhimanyu
05/13/2024, 7:57 AMDestructuring declaration initializer of type Array<Any?> must have a 'component6()' function
Csabi Szenczi
05/17/2024, 6:09 AMAbhimanyu
05/17/2024, 6:11 AMephemient
05/17/2024, 2:30 PMcomponent6
can be defined yourself, as in the previous playground linkephemient
05/17/2024, 2:31 PM