Skip to content

Reactive Plugin - Android SampleApp

Setting up plugins

Each plugin requires a Policy.json, which tells PlatformHub how it will communicate with the other plugins.

When PlatformHub initialises and starts its Policy validity checks, it will crash the app if any of the default rules are not followed. Refer to Name and UUID for more information.

Have a look at the article How to build a plugin in order to understand the plugins we have created in the Reactive Plugin Sample App project.

The Reactive Plugin sample

Each plugin's behaviour is essentially defined by its own policy file.

The following is an example of how the main ReactivePlugin is connected to the other different plugins involved in the sample.

Please, refer to each other plugin policy file to see the reciprocal relationship.

json
{
  "name": "ReactivePlugin",
  "version": "0.1",
  ...
}

Subscribing to events

Informs PlatformHub that we will subscribe to events emitted by other plugins.

json
{
  ...
  "subscribeOnStartup": {
    "eventStreams": [
      {
        "messageName": "ConnectivityStatusChanged",
        "pluginName": "ReachabilityToolPlugin"
      },
      {
        "messageName": "AccountListLoaded",
        "pluginName": "AccountDomainPlugin"
      },
      {
        "messageName": "PrimaryAccountUpdated",
        "pluginName": "AccountDomainPlugin"
      },
      ...
    ]
    ...
  }
}

Sending queries

Informs PlatformHub that we may send queries to other plugins and receive data from them.

json
{
  ...
    "send": {
        ...
        "queries": [
            {
                "messageName": "FetchAccountList",
                "pluginName": "AccountDomainPlugin"
            },
            {
                "messageName": "GetAccountDetails",
                "pluginName": "AccountDomainPlugin"
            },
            {
                "messageName": "SetPrimaryAccount",
                "pluginName": "AccountDomainPlugin"
            },
            ...
        ]
    }
}

Informs PlatformHub that we may send queries to navigate to other plugins.

json
{
  ...
  "receive": {
    ...
    "navigationQueries": [
      {
        "messageName": "NavigateToAccountsJourneyScreen",
        "pluginName": "AccountsJourneyPlugin"
      }
    ]
  }
}

Other plugins

The other plugins that the Reactive plugin is referring to, will define their reciprocal entries, so that other plugins can define their own policies.