element-x-ada/libraries
Marco Romano 316d57d1b6 Async API improvements "v2" (#672)
* Async API improvements "v2"

**NB: This PR actually changes only 3 files in `libraries/architecture/`. All the other changes are automated refactors to fix the calling code.**

This is a proposal for improvements to our `Async` type as discussed in: https://github.com/vector-im/element-x-android/pull/598/files#r1230664392 and in other chats.

Please bear in mind it is just a proposal, I'd love to hear your feedback about it, especially when it comes to naming: I've tried to make parameter and function names use a terminology similar to what we find in the Kotlin stdlib and its `Result` type.

I'm inclined to like more the non-extension flavours of the new `run*` APIs, though I'd also like your feedback about what API shape you prefer.

### Summary of the changes:
#### Functional
- Adds `exceptionOrNull()` API to complement the existing `dataOrNull()` API.
- Adds `isFailure()`, `isLoading()`, `isSuccess()` and `isUninitialized()` courtesy APIs.
- Renames `executeResult()` to `runUpdatingState()`:
	- Becomes the base API to which all the other similarly named APIs call into.
	- Makes it inline.
	- Adds contract.
	- Passes over any `prevData` to newre Async states.
	- Passes through the `block`s return value.
	- Adds unit tests.
- Renames `execute` to `runCatchingUpdatingState()` and makes it just call into `runUpdatingState()`
- Adds extension function overloads to the `run*` functions to accept `MutableState` as receiver

#### Cosmetics
- Reorders classes and methods in alphabetic order.
- Reorder parameter names to mimic conventions in Kotlin stdlib.
- Adds docstrings where useful.

* Use `fold()`

* rename pop to popFirst

* Add docstrings

* Please Detekt

* Rename exception to error.

* Please detekt

* Update existing usages.
2023-06-27 13:37:23 +02:00
..
androidutils Move FileSizeFormatter to module :libraries:androidutils 2023-06-26 11:14:53 +02:00
architecture Async API improvements "v2" (#672) 2023-06-27 13:37:23 +02:00
core Merge branch 'develop' into feature/fga/pdf_renderer 2023-06-02 16:43:55 +02:00
coroutines Update Gradle to 8.1 and AGP to v8.0 (#329) 2023-04-17 08:49:52 +00:00
dateformatter Update Gradle to 8.1 and AGP to v8.0 (#329) 2023-04-17 08:49:52 +00:00
deeplink Oidc with CustomTab 2023-05-30 15:59:58 +02:00
designsystem Refine handleSnackbarMessage API (#676) 2023-06-26 16:29:50 +02:00
di Update Gradle to 8.1 and AGP to v8.0 (#329) 2023-04-17 08:49:52 +00:00
elementresources Update Gradle to 8.1 and AGP to v8.0 (#329) 2023-04-17 08:49:52 +00:00
encrypted-db Update Gradle to 8.1 and AGP to v8.0 (#329) 2023-04-17 08:49:52 +00:00
eventformatter Sync Strings from Localazy 2023-06-26 00:10:53 +00:00
featureflag Move the button to open the Showkase browser to the developer settings screen. (#389) 2023-05-04 17:29:03 +02:00
matrix Add sendLocation API to Rust Room (#681) 2023-06-27 09:12:17 +02:00
matrixui Lazy usage of OkHttpClient 2023-06-26 11:07:53 +02:00
mediapickers Fix tests after rebase 2023-05-11 16:30:37 +02:00
mediaupload Rust sdk update: make the app compile 2023-06-22 09:50:17 +02:00
network Lazy use the OkHttpClient. 2023-06-07 09:06:46 +02:00
permissions Remove useless OptIn in tests 2023-05-12 10:05:39 +02:00
push Update dependency org.matrix.rustcomponents:sdk-android to v0.1.24 (#675) 2023-06-27 08:29:36 +02:00
pushproviders Init analytics modules (#350) 2023-06-05 13:11:34 +00:00
pushstore Remove useless OptIn in tests 2023-05-12 10:05:39 +02:00
rustsdk convert rustsdk gradle file to kts 2023-04-04 15:44:37 +02:00
session-storage Fix detected forbidden pattern. 2023-05-31 15:31:05 +02:00
testtags Update maestro test regarding the new login flow. 2023-06-09 10:19:49 +02:00
textcomposer Sync Strings from Localazy 2023-06-26 00:10:53 +00:00
ui-strings Sync Strings from Localazy 2023-06-26 00:10:53 +00:00
usersearch Merge remote-tracking branch 'origin/develop' into misc/cjs/create-join-design-feedback 2023-06-01 13:26:27 +01:00