Skip to content

Commit

Permalink
fix some mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
fumito-ito committed May 22, 2022
1 parent cfcb1b7 commit 9e7ba43
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
11 changes: 11 additions & 0 deletions Example.swiftpm/ViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import Combine
final class ViewModel: ObservableObject {
@Published var contentText: String

@SwiftyRemoteConfig(keyPath: \.contentText)
var fuga: String

private var cancellables: Set<AnyCancellable> = []

init() {
Expand All @@ -25,3 +28,11 @@ final class ViewModel: ObservableObject {
.store(in: &cancellables)
}
}

final class Foo {
init() {
let viewModel = ViewModel()

let foo = viewModel.$fuga.lastFetchTime
}
}
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,18 @@ You can also check property details with projected value:

```swift
struct Settings {
@SwiftyRemoteConfig(keyPath: \.userColorScheme)
var userColorScheme: String

var isFetchedOnce: Bool {
// you can also use `_userColorScheme.lastFetchStatus`
return _userColorScheme.lastFetchTime != nil
}
@SwiftyRemoteConfig(keyPath: \.newFeatureAvailable)
var newFeatureAvailable: String
}

struct NewFeatureRouter {
func show(with settings: Settings) {
if settings.$newFeatureAvailable.lastFetchTime != nil {
// show new feature
} else {
// fetch and activate remote config before routing
}
}
}
```

Expand Down
8 changes: 4 additions & 4 deletions Sources/SwiftyRemoteConfig/PropertyWrappers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public final class SwiftyRemoteConfig<T: RemoteConfigSerializable> where T.T ==
return self.config.lastFetchTime
}

public var projectedValue: T {
public var projectedValue: SwiftyRemoteConfig<T> {
get {
return self.wrappedValue
return self
}
@available(*, unavailable, message: "SwiftyRemoteConfig property wrapper does not support setting values yet.")
@available(*, unavailable, message: "SwiftyRemoteConfig's projected value does not support setting values yet.")
set {
fatalError("SwiftyRemoteConfig property wrapper does not support setting values yet.")
fatalError("SwiftyRemoteConfig's projected value does not support setting values yet.")
}
}

Expand Down

0 comments on commit 9e7ba43

Please sign in to comment.