Architecture - wordpress-mobile/WordPress-FluxC-Android GitHub Wiki
General diagram of the FluxC architecture:

In the new architecture we're using Kotlin and coroutines instead of Dispatcher. New calls are now synchronous and defined as suspend. The dispatcher still exists and is used for backward compatibility. It is an event bus that should be used to broadcast events.
Notes:
- WP REST API client is not implemented yet (we have a proof of concept and discovery utils).
- Memory storage is optional, it makes sense to have some data in memory so we don't have to hit the DB everytime we call a Store's getter. The Account Store is currently the only Store using data stored in memory.
The calls to FluxC are now synchronous with the Store being the orchestrator of the flow:
- App sends synchronous requests to the Store suspended function with an Action as a parameter.
- Store sends request to the RestClient which synchronously waits for the Response from the API
- RestClient returns the Fetched Payload object back to the Store
- Store can send the object to the SqlUtils class to store it in DB
- Store returns the OnChanged event back to the app.
- App loads data via previously existing getters
Example:
- App asks FluxC to
FETCH_ACTIVITY_LOGfor site X by callingActivityLogStore::fetchActivitiesmethod and suspends the current coroutine. ActivityLogStorecalls theActivityLogRestClient::fetchActivityand awaits result.ActivityLogRestClientcallsWPComGsonRequestBuilder::syncGetRequestand awaits result.WPComGsonRequestBuilderbuilds a get request, adds it to the request queue and transforms callback to a synchronous call usingsuspendCoroutine.ActivityLogRestClientreceives aResponse, transforms it into aFetchedActivityLogPayloadand returns it to theActivityLogStoreActivityLogStorereceives the payload and stores it into DB usingActivityLogSqlUtilsActivityLogStorereturnsOnActivityLogFetchedobject containing the change information back to the app.- App loads Activity log using
ActivityLogStore::getActivityLogForSite