PubSub
The PubSub plugin adds a publish/subscribe interface between the host app and Player’s content.
Usage
Add the plugin to Player:
To unsubscribe:
The PubSubPlugin
provides support for handling the publish expressions in Player content at the app level. The PubSubPlugin is included by default in the Android Player, so configuring events subscriptions can be done on Player using the provided extension methods.
If your content uses the @[ publish() ]@
expression for actions, you can subscribe to these events by using the PubSubPlugin
.
CocoaPods
Add the subspec to your Podfile
Swift Usage
If your content uses a different name for publishing (such as publishEvent
) you can customize the expression name that the plugin uses:
Then, just include it in your plugins
to a Player instance:
Note: AnyType is a custom enum type to handle the arbitrary types that can be received from these events, as the data is set in your Player Content, ensure that it matches either String, [String], or [String: String].
Publish Expression
To trigger an event to be published, use the publish()
expression in Player’s content: