Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates API documentation based on technical writing suggestions. #146

Merged
merged 5 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/SwiftCurrent/Models/Workflow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Foundation
A doubly linked list of `FlowRepresentableMetadata`s; used to define a process.

### Discussion
In a sufficiently complex application it may make sense to create a structure to hold onto all the workflows in an application.
In a sufficiently complex application, it may make sense to create a structure to hold onto all the workflows in an application.

#### Example
```swift
Expand Down
16 changes: 8 additions & 8 deletions Sources/SwiftCurrent/Protocols/FlowRepresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ import Foundation
- Important: If you create a superclass that is a `FlowRepresentable` and expect subclasses to be able to define their own methods, such as `shouldLoad`, the superclass should declare those methods, and the subclasses should override them. Otherwise you will find the subclasses do not behave as expected.

#### Example
A `FlowRepresentable` with a `WorkflowInput` of `String` and a `WorkflowOutput` of `Never`
A `FlowRepresentable` with a `WorkflowInput` of `String` and a `WorkflowOutput` of `Never`:
morganzellers marked this conversation as resolved.
Show resolved Hide resolved
```swift
class FR1: FlowRepresentable { // Mark this class as `final` to avoid the required keyword on init
weak var _workflowPointer: AnyFlowRepresentable?
required init(with name: String) { }
}
```

A `FlowRepresentable` with a `WorkflowInput` of `Never` and a `WorkflowOutput` of `Never`
A `FlowRepresentable` with a `WorkflowInput` of `Never` and a `WorkflowOutput` of `Never`:
morganzellers marked this conversation as resolved.
Show resolved Hide resolved
```swift
final class FR1: FlowRepresentable { // Classes synthesize an empty initializer already, you are good!
weak var _workflowPointer: AnyFlowRepresentable?
}
```

#### Note
Declaring your own custom initializer can result in a compiler error with an unfriendly message
Declaring your own custom initializer can result in a compiler error with an unfriendly message.
```swift
class FR1: FlowRepresentable { // Results in compiler error for 'init()' being unavailable
weak var _workflowPointer: AnyFlowRepresentable?
Expand All @@ -56,19 +56,19 @@ public protocol FlowRepresentable {
A pointer to the `AnyFlowRepresentable` that erases this `FlowRepresentable`; will automatically be set.

### Discussion
This property is automatically set by a `Workflow`, it simply needs to be declared on a `FlowRepresentable`.
In order for a `FlowRepresentable` to have access to the `Workflow` that launched it, store the closures for proceeding forward and backward, and provide type safety, it needs this property available for writing.
This property is automatically set by a `Workflow`; it simply needs to be declared on a `FlowRepresentable`.
In order for a `FlowRepresentable` to have access to the `Workflow` that launched it, store the closures for proceeding forward and backward, and provide type safety. It needs this property available for writing.

#### Note
While not strictly necessary it would be wise to declare this property as `weak`.
While not strictly necessary, it would be wise to declare this property as `weak`.
*/
var _workflowPointer: AnyFlowRepresentable? { get set }

/**
Creates a `FlowRepresentable`.

#### Note
This is auto synthesized by FlowRepresentable, and is only called when `WorkflowInput` is `Never`.
This is auto-synthesized by FlowRepresentable, and is only called when `WorkflowInput` is `Never`.
*/
init()
/// Creates a `FlowRepresentable` with the specified `WorkflowInput`.
Expand All @@ -87,7 +87,7 @@ public protocol FlowRepresentable {
### Discussion
This method is called *after* `init` but *before* any other lifecycle events. It is non-mutating and should not change the `FlowRepresentable`.

- Important: If you create a superclass that is a `FlowRepresentable` and expect subclasses to define their own `shouldLoad` the superclass should declare `shouldLoad`, and the subclasses should override it. Otherwise you will find the subclasses do not behave as expected.
- Important: If you create a superclass that is a `FlowRepresentable` and expect subclasses to define their own `shouldLoad`, the superclass should declare `shouldLoad`, and the subclasses should override it. Otherwise you will find the subclasses do not behave as expected.

#### Note
Returning `false` can have different behaviors depending on the `FlowPersistence`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ extension UIViewController {

extension FlowRepresentable where Self: UIViewController {
/**
Called when the current workflow should be terminated, and the app should return to the point before the workflow was launched
- Parameter animated: A boolean indicating whether abandoning the workflow should be animated
- Parameter onFinish: A callback after the workflow has been abandoned.
- Note: In order to dismiss UIKit views the workflow must have an `OrchestrationResponder` that is a `UIKitPresenter`.
Called when the current workflow should be terminated, and the app should return to the point before the workflow was launched.
- Parameter animated: a boolean indicating whether abandoning the workflow should be animated.
- Parameter onFinish: a callback after the workflow has been abandoned.
- Note: In order to dismiss UIKit views, the workflow must have an `OrchestrationResponder` that is a `UIKitPresenter`.
*/
public func abandonWorkflow(animated: Bool = true, onFinish:(() -> Void)? = nil) {
workflow?.abandon(animated: animated, onFinish: onFinish)
Expand Down