Skip to content

Commit 48f7835

Browse files
committed
Version update
1 parent b98a293 commit 48f7835

File tree

5 files changed

+30
-19
lines changed

5 files changed

+30
-19
lines changed

Package.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
import PackageDescription
44

55
let package = Package(
6-
name: "weak",
6+
name: "swift-capture",
77
products: [
88
.library(
9-
name: "Weak",
10-
targets: ["Weak"]
9+
name: "Capture",
10+
targets: ["Capture"]
1111
)
1212
],
1313
targets: [
14-
.target(name: "Weak"),
14+
.target(name: "Capture"),
1515
.testTarget(
16-
name: "WeakTests",
16+
name: "CaptureTests",
1717
dependencies: [
18-
.target(name: "Weak")
18+
.target(name: "Capture")
1919
]
2020
),
2121
]

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Weak
1+
# swift-capture
22

33
[![SwiftPM 5.3](https://img.shields.io/badge/📦_spm-5.3-ED523F.svg?style=flat)](https://swift.org/download/) [![@maximkrouk](https://img.shields.io/badge/[email protected]?style=flat&logo=twitter)](https://twitter.com/maximkrouk)
44

@@ -58,7 +58,7 @@ Methods
5858
```
5959

6060
```swift
61-
capture(in: Self.someMethod)
61+
capture(Self.someMethod)
6262
```
6363

6464
----
@@ -83,7 +83,7 @@ let object.dataSource = capture(or: [], in: \.data)
8383
You can add `weak` to an Xcode project by adding it as a package dependency.
8484

8585
1. From the **File** menu, select **Swift Packages › Add Package Dependency…**
86-
2. Enter [`"https://github.com/makeupstdio/weak"`](https://github.com/makeupstdio/weak) into the package repository URL text field
86+
2. Enter [`"https://github.com/capturecontext/swift-capture"`](https://github.com/capturecontext/swift-capture) into the package repository URL text field
8787
3. Choose products you need to link them to your project.
8888

8989
### Recommended
@@ -93,17 +93,18 @@ If you use SwiftPM for your project, you can add `weak` to your package file. Al
9393
```swift
9494
.package(
9595
name: "weak",
96-
url: "[email protected]:makeupstudio/weak.git",
97-
.branch("main")
96+
url: "[email protected]:capturecontext/swift-capture.git",
97+
.upToNextMajor("2.0.0")
9898
)
9999
```
100100

101101
Do not forget about target dependencies:
102102

103103
```swift
104104
.product(
105-
name: "Weak",
106-
package: "weak"
105+
name: "swift-capture",
106+
name: "Capture",
107+
package: "swift-capture"
107108
)
108109
```
109110

Sources/Weak/Weak.swift renamed to Sources/Capture/Weak.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ extension Weak {
363363

364364
extension Weak {
365365
public func capture(
366-
in closure: @escaping (Object) -> (() -> Void)
366+
_ closure: @escaping (Object) -> (() -> Void)
367367
) -> (() -> Void) {
368368
return { [weak wrappedValue] in
369369
guard let object = wrappedValue else { return }

Sources/Weak/Weakifiable.swift renamed to Sources/Capture/Weakifiable.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,17 @@ extension Weakifiable {
156156
}
157157

158158
extension Weakifiable {
159-
public func capture(in closure: @escaping (Self) -> (() -> Void)) -> (() -> Void) {
160-
Weak(self).capture(in: closure)
159+
public func capture(
160+
_ closure: @escaping (Self) -> (() -> Void)
161+
) -> (() -> Void) {
162+
Weak(self).capture(closure)
163+
}
164+
}
165+
166+
extension Weakifiable {
167+
public func captureAssign<Value>(
168+
to keyPath: ReferenceWritableKeyPath<Self, Value>
169+
) -> (Value) -> Void {
170+
Weak(self).capture { $0[keyPath: keyPath] = $1 }
161171
}
162172
}

Tests/WeakTests/WeakTests.swift renamed to Tests/CaptureTests/CaptureTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import XCTest
2-
@testable import Weak
2+
@testable import Capture
33

44
final class WeakTests: XCTestCase {
55
class Object: Weakifiable {
@@ -151,8 +151,8 @@ final class WeakTests: XCTestCase {
151151
isObjectDeinitialized = true
152152
})
153153

154-
let closure1: () -> Void = object!.capture(in: LocalObject.doSomething)
155-
let closure2: () -> Void = object!.capture(in: LocalObject.undoSomething)
154+
let closure1: () -> Void = object!.capture(LocalObject.doSomething)
155+
let closure2: () -> Void = object!.capture(LocalObject.undoSomething)
156156
let closure3: () -> Bool = object!.capture(or: false, in: \.didSomething)
157157

158158
XCTAssertEqual(object?.didSomething, false)

0 commit comments

Comments
 (0)