Skip to content

Instantly share code, notes, and snippets.

@kraigspear
Last active June 19, 2020 10:12
Show Gist options
  • Save kraigspear/519e2021910f86910c0b413b2876e86c to your computer and use it in GitHub Desktop.
Save kraigspear/519e2021910f86910c0b413b2876e86c to your computer and use it in GitHub Desktop.
Adding a publisher to a protocol
protocol VehicleDataLoadable {
var vehiclePublisher: Published<Vehicle?>.Publisher { get }
}
final class VehicleDataLoader: VehicleDataLoadable {
@Published var vehicle: Vehicle?
var vehiclePublisher: Published<Vehicle?>.Publisher { $vehicle }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment