Partial Match
This plugin enables users to map matches of assets to any arbitrary value in a partial-match-registry. For each asset in a resolved view, the matches will be computed.
Create a registry and add matches:
import { Registry } from "@player-ui/partial-match-registry";
const registry = new Registry([[{ type: "action" }, "ABC"]]);Add the registy to a plugin:
import { Player } from "@player-ui/player";import { PartialMatchFingerprintPlugin } from "@player-ui/partial-match-fingerprint-plugin";
const matchPlugin = new PartialMatchFingerprintPlugin(registry);
const player = new Player({ plugins: [matchPlugin],});Query the plugin for matches:
const value = matchPlugin.get("asset-id"); // 'ABC'This plugin is used by BaseAssetRegistry to handle matching resolved asset nodes with their native implementation, to decode for rendering. It is unlikely to be needed to be used directly in iOS use cases.
CocoaPods
Add the subspec to your Podfile.
pod 'PlayerUI/PlayerUI'In your Swift file, import the pod. Only one import is needed for all PlayerUI pods.
import PlayerUISwift Package Manager
Add the product to the appropriate target's dependencies in your Package.swift.
.target( name: "MyApp", dependencies: [ .product(name: "PlayerUIPlayerUI", package: "playerui-swift-package"), ])In your Swift file, import the sub-package. A different import is needed for each PlayerUI sub-package.
import PlayerUIPlayerUISwift Usage
Section titled “Swift Usage”let plugin = PartialMatchFingerprintPlugin()
// iOS usage links the array position of a registered asset to its requested match object// The JavaScript part of this plugin will populate matches when the view is resolvingplugin.register(match: ["type": "text"], index: 1)
// get the index for the asset with matching ID if it was resolved in the core pluginplugin.get(assetId: "test")