StepRunner

public class StepRunner

The StepRunner is the engine that runs the steps in the pipeline.

Once initialized, call the run() method to execute the steps, and observe the state property to be notified of progress and status.

  • The observable state which indicates the progress and status.

    Declaration

    Swift

    public private(set) var state: StepRunnerState { get set }
  • Callbacks which are called on each state change

    Declaration

    Swift

    public var stateObservers: [(StepRunnerState) -> Void]
  • A model dictionary which can be used to pass data from step to step.

    Declaration

    Swift

    public private(set) var model: JSON { get }
  • Initializer to create the StepRunner.

    Declaration

    Swift

    public init(
        moduleName: String,
        steps: [Step],
        scriptBundle: Bundle = Bundle.main,
        customUserAgent: String? = nil,
        completion: (() -> Void)? = nil
    ) throws

    Parameters

    moduleName

    The name of the JavaScript module which has your customer functions. By convention, the filename of the JavaScript file is the same as the module name.

    steps

    The steps to run in the pipeline.

    scriptBundle

    The bundle from which to load the JavaScript file. Defaults to the main bundle.

    customUserAgent

    The custom user agent string (only works for iOS 9+).

  • Execute the steps.

    Declaration

    Swift

    public func run(completion: (() -> Void)? = nil)
  • Resets the existing StepRunner and execute the given steps in the existing browser.

    Use this to perform more steps on a StepRunner which has previously finished processing.

    Declaration

    Swift

    public func run(steps: [Step], completion: (() -> Void)? = nil)
  • Insert the WebView used for scraping at index 0 of the given parent view, using AutoLayout to pin all 4 sides of the parent.

    Useful if the app would like to see the scraping in the foreground.

    Declaration

    Swift

    public func insertWebViewIntoView(parent: PlatformView)