WordPress-FluxC-Android is a networking and persistence library that helps to connect and sync data from a WordPress site (self hosted, or wordpress.com site).
Based on the Flux pattern, we're using: Dagger2 for dependency injection, WellSql for persistence.
FluxC is pronounced ‘fluxy’, and stands for ‘Flux Capacitor’. This makes a double reference to the architecture model (since a capacitor is a kind of storage unit, or ‘store’). More importantly, a flux capacitor is the core component of the DeLorean time machine in Back to the Future, which ‘makes time travel possible.’
Most of our documentation for using and contributing to FluxC can be found in our wiki.
Please see our Using FluxC wiki page for setup instructions.
The gradle build system will fetch all dependencies and generate files you need to build the project. You first need to generate the local.properties (replace YOUR_SDK_DIR with your actual android SDK directory) file and create the gradle.properties file. The easiest way is to copy our example:
$ echo "sdk.dir=YOUR_SDK_DIR" > local.properties
$ ./gradlew fluxc:build
$ cp example/gradle.properties-example example/gradle.properties
$ cp example/tests.properties-example example/tests.properties
$ ./gradlew cAT # Regression tests
$ ./gradlew testDebug # Unit tests
Note: this is the default example/gradle.properties
file. You'll have to get
a WordPress.com OAuth2 ID and secret.
We have some tests connecting to real HTTP servers, URL and credentials are defined in example/tests.properties
, you must edit it or obtain the real file to run the tests.
Please note that, unless using special credentials which cannot be shared publicly, some of the WordPress.com connected tests will not pass unless the OAuth2 ID and secret are registered to the account that the test is attempting to log into.
The FluxC project uses Checkstyle. You can run checkstyle using ./gradlew checkstyle
. You can also view errors and warnings in realtime with the Checkstyle plugin. When importing the project into Android Studio, Checkstyle should be set up automatically. If it is not, follow the steps below.
You can install the CheckStyle-IDEA plugin in Android Studio here:
Android Studio > Preferences... > Plugins > CheckStyle-IDEA
Once installed, you can configure the plugin here:
Android Studio > Preferences... > Other Settings > Checkstyle
From there, add and enable the configuration file for FluxC, located at config/checkstyle.xml.
The FluxC project uses ktlint for Kotlin linting. You can run ktlint using ./gradlew ktlint
, and you can also run ./gradlew ktlintFormat
for auto-formatting. There is no IDEA plugin (like Checkstyle's) at this time.
Each store should have a corresponding enum defining actions for that store. For example, SiteStore's actions are defined in the SiteAction enum.
Action naming guide:
FETCH_X - request data from the server
PUSH_X - send data to the server
UPDATE_X - local change
REMOVE_X - local remove
DELETE_X - request deletion on the server
Each action enum should be annotated with @ActionEnum
, with individual actions receiving an @Action
annotation with an optional payloadType
setting (see SiteAction for an example).
Endpoints for each of the supported APIs are centralized in a generated endpoint file: WPCOMREST.java
and XMLRPC.java
(also WPAPI.java
).
To add a new endpoint, first add it to the appropriate fluxc/src/main/tools/*.txt
file, and then rebuild the project to update the generated (Java) endpoint file.
Note that, for WordPress.com REST API endpoints, the final endpoint will be normalized to include a trailing slash.
All On Changed Events extend the OnChanged class. They encapsulate an error
field. Events can be checked for an error by calling event.isError()
.
On Changed Events naming guide:
onXChanged(int rowsAffected) - Keep X singular even if multiple X were changed
onXRemoved(int rowsAffected) - Keep X singular even if multiple X were removed
Say hello on our Slack channel: #mobile
.
WordPress-FluxC-Android is an Open Source project covered by the GNU General Public License version 2.