Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save karigrooms/6a97858f24c1078aaf1801b036e77ba5 to your computer and use it in GitHub Desktop.
Save karigrooms/6a97858f24c1078aaf1801b036e77ba5 to your computer and use it in GitHub Desktop.
Blog: ObservableObjects and Protocols - Example ObservableObject
// Copyright 2021 Expedia, Inc.
// SPDX-License-Identifier: Apache-2.0
import Combine
struct Price {
let amount: String // "$42"
let description: String // "avg/night"
}
class PricingProvider: ObservableObject {
@Published private(set) var price: Price?
init(price initialValue: Price? = nil) {
self.price = initialValue
}
func fetch() {
//.. fetch pricing from a service
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment