https://github.com/combinecommunity/combineprintout
A Combine micro debugging package
https://github.com/combinecommunity/combineprintout
Last synced: about 1 year ago
JSON representation
A Combine micro debugging package
- Host: GitHub
- URL: https://github.com/combinecommunity/combineprintout
- Owner: CombineCommunity
- License: mit
- Created: 2019-08-15T18:00:38.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-15T18:31:49.000Z (almost 7 years ago)
- Last Synced: 2025-04-19T22:12:45.557Z (about 1 year ago)
- Language: Swift
- Homepage: http://combineopensource.org
- Size: 31.3 KB
- Stars: 55
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

A Combine micro debugging framework. It helps you log subscription events to the console so you can track their life cycle.
## Usage
#### A debugging print sink
The built-in `print()` operator is useful but you still need to add a subscriber to your subscription. `printSink()` is a subscriber that you can use to debug a subscription without the need to add a separate subscriber like so:
```swift
Just(["One", "Two"])
.printSink()
```
`printSink()` will subscribe the publisher and log all events like so:
```none
Sink: output(["One", "Two"])
Sink: finished
```
#### A debugging print cancellable
If you're building more complex memory management logic or not sure when are your cancellables released you can use `printCancellable()` to log a given `Cancellable`'s life cycle like so:
```swift
Just(["One", "Two"])
.assign(to: \.model, on: self)
.printCancellable()
.store(in: &subscriptions)
```
`printCancellable()` wraps the `AnyCancellable` returned from `assign(to:on:)` and logs all the received events:
```none
Cancellable: init
...
(self.subscriptions is released from memory)
...
Cancellable: cancel
Cancellable: deinit
```
## Installation
### Swift Package Manager
Add the following dependency to your **Package.swift** file:
```swift
.package(url: "https://github.com/combineopensource/CombinePrintout, from: "0.2")
```
## License
CombineOpenSource is available under the MIT license. See the LICENSE file for more info.
## Credit
Copyright (c) 2019 Combine Open Source
Created by: Marin Todorov