Stage Revert Data
This plugin enables users to temporarily stage data changes before committing to the actual data model
A stageData property flag inside of the view properties must be added on the desired view configs.
{ "VIEW_1": { "state_type": "VIEW", "ref": "view-1", "attributes": { "stageData": true, "commitTransitions": ["VIEW_2"] }, "transitions": { "next": "VIEW_2", "*": "ACTION_1" } }}It also should include a list of acceptable commitTransitions valid VIEW name for the data to be committed when the transition occurs, A not included commit transition would trigger the staged data to be cleared. An acceptable transition will commit the data into the data model. e.g. as per the previous example transitioning to VIEW_2 will trigger the staged data to get committed in the model, since the next transition property is pointing to it and is listed on the commitTransitions array parameter, otherwise it would get thrown away.
Example
Section titled “Example”Simply add the plugin to the config when constructing a player instance.
import StageRevertPlugin from "@player/stage-revert-data";
const player = new Player({ plugins: [new StageRevertPlugin()],});CocoaPods
Add the subspec to your Podfile.
pod 'PlayerUI/StageRevertDataPlugin'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: "PlayerUIStageRevertDataPlugin", package: "playerui-swift-package"), ])In your Swift file, import the sub-package. A different import is needed for each PlayerUI sub-package.
import PlayerUIStageRevertDataPluginSwift Usage
Section titled “Swift Usage”This plugin takes no parameters, and the configuration comes from content, it can just be added to the plugin array:
var body: some View { SwiftUIPlayer( flow: flow, plugins: [ StageRevertDataPlugin() ], result: $resultBinding )}