Timelane + Combine

TimelaneCombine

TimelaneCombine 提供 Combine 绑定,用于使用 Timelane Instrument 分析 Combine 代码。

Timelane Instrument

目录

用法

注意: 要观察使用 TimelaneCombine 的输出,您需要提前安装 Timelane Instrument。 更多信息请访问:http://timelane.tools

在您的代码中导入 TimelaneCombine 框架

import TimelaneCombine

使用 lane(_) 操作符通过 TimelaneInstrument 分析订阅。 将 lane(_) 插入到您要分析的代码中的精确位置,如下所示:

downloadImage(at: url).
  .lane("Download: \(url.path)")
  .assign(to: \.image, on: myImageView)

然后,通过点击 Xcode 主菜单中的Product > Profile来分析您的项目。

选择 Timelane Instrument 模板

Timelane Instrument Template

在时间线上检查您的订阅

Timelane Live Recording

有关更详细的演练,请访问 http://timelane.tools

参考

lane(_:filter:)

使用 lane("Lane name") 将数据发送到 Timelane Instrument 中的订阅和事件通道。

lane("Lane name", filter: [.subscriptions]) 将开始/完成事件发送到订阅通道。 如果您只想观察并发订阅,请使用此语法。

lane("Lane name", filter: [.events]) 将事件和值发送到事件通道。 如果您只对订阅将发出的值(例如,主题)感兴趣,请使用此过滤器。

此外,您可以使用可选的 transformValue 尾随闭包来转换 Timelane 中记录的值。

lane("Lane name") { value in
  return "Value: \(value)"
}

如果您正在使用 @Published,您可以通过将其替换为以下内容来轻松地将该订阅记录到 Timelane:

@PublishedOnLane("My Lane") var property: String

安装

Swift Package Manager

I . 在 Xcode 中自动添加

II . 在您的 Package.swift 文件中手动添加

.package(url: "https://github.com/icanzilb/TimelaneCombine", from: "2.0.0")

CocoaPods

CocoaPods 是 Cocoa 项目的依赖管理器。 有关使用和安装说明,请访问他们的网站。 要使用 CocoaPods 将 TimelaneCombine 集成到您的 Xcode 项目中,请在您的 Podfile 中指定它:

pod 'TimelaneCombine', '~> 2.0'

演示

Timelane 包包含一个演示应用程序,位于:https://github.com/icanzilb/timelane

许可证

版权所有 (c) Marin Todorov 2020。此软件包根据 MIT 许可证提供。