StandardActionConvertible

public protocol StandardActionConvertible: Action

Implement this protocol on your custom Action type if you want to make the action serializable. - Note: We are working on a tool to automatically generate the implementation of this protocol for your custom action types.

  • Within this initializer you need to use the payload from the StandardAction to configure the state of your custom action type.

    Example:

    init(_ standardAction: StandardAction) {
    self.twitterUser = decode(standardAction.payload!["twitterUser"]!)
    }
    

    Note

    If you, as most developers, only use action serialization/deserialization during development, you can feel free to use the unsafe ! operator.
    Declaration

    Swift

    init (_ standardAction: StandardAction)
  • Use the information from your custom action to generate a StandardAction. The type of the StandardAction should typically match the type name of your custom action type. You also need to set isTypedAction to true. Use the information from your action’s properties to configure the payload of the StandardAction.

    Example:

    func toStandardAction() -> StandardAction {
    let payload = ["twitterUser": encode(self.twitterUser)]
    
    return StandardAction(type: SearchTwitterScene.SetSelectedTwitterUser.type,
    payload: payload, isTypedAction: true)
    }
    
    Declaration

    Swift

    func toStandardAction() -> StandardAction