workflow-swift icon indicating copy to clipboard operation
workflow-swift copied to clipboard

WIP WorkflowUI Observation with enum

Open amorde opened this issue 1 year ago • 0 comments

Compare with https://github.com/square/workflow-swift/pull/208 and https://github.com/square/workflow-swift/pull/209

Pros

  • Concise observer protocol definition
  • Concise list of events
  • Enum enables switching over all possible events
  • Somewhat portable to other observation systems (ex. FRP frameworks)

Cons

  • Adding a new field to an existing enum is backwards incompatible
  • Adding a new case to the enum is backwards incompatible
  • Enums lack the ability to have standard fields for all cases (ex. base class with set of properties). This can be worked around by injecting things into the observation function instead of the enum case, but then the enum case is less reusable in other contexts as you would need to forward the extra data along with it
  • Consumers all must switch over every event which may reduce performance and add friction (ex. if I only want to listen for viewDidAppear)
  • Does not match existing observation APIs for Workflow

amorde avatar May 11 '23 14:05 amorde