Last active
November 15, 2021 16:44
-
-
Save karigrooms/6a97858f24c1078aaf1801b036e77ba5 to your computer and use it in GitHub Desktop.
Blog: ObservableObjects and Protocols - Example ObservableObject
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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