How johnsundell/flow works
Project Type & Purpose
• Flow is an open-source Swift library (not a standalone app) providing a lightweight, operation-oriented programming model.
• Purpose: let client code define atomic “operations” (sync or async), then compose them into sequences, groups, queues or repeaters, simplifying complex asynchronous flows.
Key Architectural Components
A. Protocol Layer
• FlowOperation (core protocol for any atomic task)
• FlowOperationCollection (protocol for any multi-operation construct)
B. Core Engine
• Internal scheduler/executor driving operation lifecycle (invoke perform(), manage completion callbacks)
C. Built-In Operations
• FlowClosureOperation, FlowAsyncClosureOperation, FlowDelayOperation
D. Operation Collections
• FlowOperationSequence (serial execution)
• FlowOperationGroup (parallel execution)
• FlowOperationQueue (continual execution)
• FlowOperationRepeater (repeat logic)
E. Integration & Packaging
• Swift Package Manager (Package.swift)
• CocoaPods podspec, Carthage compatibility
• Xcode project with multi-platform schemes (iOS, macOS, tvOS, watchOS)
• Travis CI config
F. Tests
• FlowTests target under Tests/FlowTests.swift
Relationships & Data Flow
• Client App → imports Flow library
• Client defines custom types conforming to FlowOperation
• Client or built-in code composes operations into a collection (Sequence / Group / Queue / Repeater)
• Collection invokes each operation’s perform(completionHandler:)
• Core Engine coordinates callbacks → advances collection → signals final completion back to Client
Architectural Patterns & Principles
• Protocol-oriented design (FlowOperation, FlowOperationCollection)
• Composition over inheritance (operations + collections)
• Single Responsibility (each operation does one job)
• Dependency Injection (operations are initialized with dependencies)
• Platform-agnostic core (pure Swift, no UIKit/AppKit baggage)
Elements
• “Conforms to” from Built-In Operations and Custom Ops → FlowOperation protocol
• “Uses” from Collections → FlowOperation
• “Drives” from Core Engine → Collections/Operations
• “Imported by” from Client Code → Flow module
• Concrete classes (operations, collections) in another (e.g., rectangles)
• External/integration elements (clients, CI, package managers) in a third (e.g., clouds)