Skip to content

Publish debugging information#147

Merged
tinder-cfuller merged 5 commits intomainfrom
debug-information
Jul 22, 2022
Merged

Publish debugging information#147
tinder-cfuller merged 5 commits intomainfrom
debug-information

Conversation

@tinder-cfuller
Copy link
Contributor

@tinder-cfuller tinder-cfuller commented Jul 22, 2022

Usage Example

func format<T>(_ type: T) -> String {
    let type: String = "\(type)"
    let suffix: String = "FlowImp"
    let name: String = type.hasSuffix(suffix)
        ? String(type.dropLast(suffix.count))
        : type
    return "`\(name)`"
}

DebugInformation
    .publisher()
    .sink {
        switch $0 {
        case let .flowWillStart(_, flowType, _):
            print(format(flowType), "will start")
        case let .flowDidEnd(_, flowType):
            print(format(flowType), "did end")
        case let .flowWillAttachSubFlow(_, flowType, _, subFlowType):
            print(format(flowType), "will attach", format(subFlowType))
        case let .flowDidDetachSubFlow(_, flowType, _, subFlowType):
            print(format(flowType), "did detach", format(subFlowType))
        case let .flowControllerWillAttachFlow(_, _, flowType):
            print("flow controller will attach", format(flowType))
        case let .flowControllerDidDetachFlow(_, _, flowType):
            print("flow controller did detach", format(flowType))
        }
    }
    .store(in: &cancellables)

Output:

`App` will start
`App` will attach `Scene`
flow controller will attach `Scene`
`Scene` will start
`Scene` will attach `Window`
flow controller will attach `Window`
`Window` will start
`Window` will attach `Root`
flow controller will attach `Root`
`Root` will start

Copy link
Contributor

@tinder-matthewmourlam tinder-matthewmourlam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v nice!

@tinder-cfuller tinder-cfuller merged commit 576708b into main Jul 22, 2022
@tinder-cfuller tinder-cfuller deleted the debug-information branch July 22, 2022 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework Framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants