Skip to content

Commit

Permalink
Merge pull request #117 from AckeeCZ/publisher-extensions
Browse files Browse the repository at this point in the history
Publisher extensions
  • Loading branch information
olejnjak authored Mar 31, 2022
2 parents 3598470 + a2b2baa commit 1bb67ae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ACKategories.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
/* End PBXAggregateTarget section */

/* Begin PBXBuildFile section */
0E3478AB27E37DC1004548B3 /* PublisherExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3478AA27E37DC1004548B3 /* PublisherExtensions.swift */; };
6914B1142728231300FF177E /* TagListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6914B1132728231300FF177E /* TagListView.swift */; };
692154722773A634007A5A5B /* IntExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69F7058D273ADBA3004DD190 /* IntExtensions.swift */; };
6922A08B273B2630004B2B1F /* IntTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6922A08A273B2630004B2B1F /* IntTests.swift */; };
Expand Down Expand Up @@ -193,6 +194,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
0E3478AA27E37DC1004548B3 /* PublisherExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PublisherExtensions.swift; sourceTree = "<group>"; };
6914B1132728231300FF177E /* TagListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagListView.swift; sourceTree = "<group>"; };
6922A08A273B2630004B2B1F /* IntTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntTests.swift; sourceTree = "<group>"; };
69372704257FAF02007CE25C /* UINavigationControllerExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UINavigationControllerExtensions.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -431,6 +433,7 @@
69F7058D273ADBA3004DD190 /* IntExtensions.swift */,
6950964A23C7751E00E8F457 /* NSAttributedStringExtensions.swift */,
6950964F23C7753500E8F457 /* NumberFormatterExtensions.swift */,
0E3478AA27E37DC1004548B3 /* PublisherExtensions.swift */,
6950965523C7754D00E8F457 /* Reusable.swift */,
6950965823C78AB900E8F457 /* StringExtensions.swift */,
6950967923C78AD000E8F457 /* UserDefaultsExtensions.swift */,
Expand Down Expand Up @@ -964,6 +967,7 @@
files = (
69F7058E273ADBA3004DD190 /* IntExtensions.swift in Sources */,
F885BDA3245ACD010071073D /* Randomizable.swift in Sources */,
0E3478AB27E37DC1004548B3 /* PublisherExtensions.swift in Sources */,
6950964423C774DB00E8F457 /* ConditionalAssignment.swift in Sources */,
6950963C23C774DB00E8F457 /* DictionaryExtensions.swift in Sources */,
6950963E23C774DB00E8F457 /* CollectionExtensions.swift in Sources */,
Expand Down
11 changes: 11 additions & 0 deletions ACKategoriesCore/PublisherExtensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Combine

@available(macOS 10.15, iOS 13.0, *)
extension Publisher where Failure == Never {
/// Weakifies `Root` object and assigns `Output` to `keyPath` on `Root`.
public func weakAssign<Root: AnyObject>(to keyPath: ReferenceWritableKeyPath<Root, Output>, on object: Root) -> AnyCancellable {
sink { [weak object] value in
object?[keyPath: keyPath] = value
}
}
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
```

## Next
- Create `PublisherExtensions.swift` and add `weakAssign(on:to:)`. ([#116](https://github.com/AckeeCZ/ACKategories/pull/116), kudos to @vendulasvastal)

- Add option to implement custom push transition ([#115](https://github.com/AckeeCZ/ACKategories/pull/115), kudos to @leinhauplk)

Expand Down

0 comments on commit 1bb67ae

Please sign in to comment.