airbnb / mavericks

Mavericks: Android on Autopilot
https://airbnb.io/mavericks/
Apache License 2.0
5.85k stars 499 forks source link

Mavericks Extensions argsOrNull #639

Closed sanogueralorenzo closed 2 years ago

sanogueralorenzo commented 2 years ago

Adding Mavericks Extensions argsOrNull which can be useful for those cases where you have an optional argument that might be sent or not.

As an example, imagine a shared screen / flow from different entry points. While this can be fixed in multiple ways in the client's code having an explicit enum that represents null / empty / none it ends up being more code which ultimately represents the same thing (although this introduces the option of nullable arguments which can also be seen as a downside)

Thoughts?

codecov[bot] commented 2 years ago

Codecov Report

Merging #639 (a9178c1) into main (f44e85b) will decrease coverage by 5.62%. The diff coverage is 11.01%.

:exclamation: Current head a9178c1 differs from pull request most recent head cde1959. Consider uploading reports for the commit cde1959 to get more accurate results

@@            Coverage Diff             @@
##             main     #639      +/-   ##
==========================================
- Coverage   55.06%   49.43%   -5.63%     
==========================================
  Files          53       54       +1     
  Lines        2508     2846     +338     
  Branches      326      338      +12     
==========================================
+ Hits         1381     1407      +26     
- Misses        976     1284     +308     
- Partials      151      155       +4     
Impacted Files Coverage Δ
.../airbnb/mvrx/compose/MavericksComposeExtensions.kt 0.00% <ø> (ø)
.../airbnb/mvrx/hilt/HiltMavericksViewModelFactory.kt 18.18% <0.00%> (ø)
...main/kotlin/com/airbnb/mvrx/mocking/MockBuilder.kt 22.01% <0.00%> (-11.73%) :arrow_down:
...main/kotlin/com/airbnb/mvrx/MavericksExtensions.kt 11.76% <50.00%> (+3.58%) :arrow_up:
...tlin/com/airbnb/mvrx/MavericksViewModelProvider.kt 88.88% <80.00%> (+0.17%) :arrow_up:
...tlin/com/airbnb/mvrx/mocking/KotlinReflectUtils.kt 66.66% <81.25%> (+8.04%) :arrow_up:
...otlin/com/airbnb/mvrx/MavericksMutabilityHelper.kt 78.94% <100.00%> (+1.16%) :arrow_up:
.../main/kotlin/com/airbnb/mvrx/MavericksViewModel.kt 60.71% <100.00%> (ø)
...rx/src/main/kotlin/com/airbnb/mvrx/PersistState.kt 79.16% <100.00%> (-1.10%) :arrow_down:
...com/airbnb/mvrx/MavericksViewModelConfigFactory.kt 73.68% <0.00%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ed755e3...cde1959. Read the comment docs.

sanogueralorenzo commented 2 years ago

@elihart what do you think of by argsOrNull?

elihart commented 2 years ago

sure, seems helpful. only comment is that it would be nice to have a test

sanogueralorenzo commented 2 years ago

Sounds good @elihart added tests https://github.com/airbnb/mavericks/pull/639/commits/cde19593968347d92d7a5fd31d13cd103951ee4d