| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- //
- // Service.swift
- // LoopKit
- //
- // Created by Darin Krauss on 5/17/19.
- // Copyright © 2019 LoopKit Authors. All rights reserved.
- //
- public protocol ServiceDelegate: AnyObject {
- /// Informs the delegate that the state of the specified service was updated and the
- /// delegate should persist the service.
- ///
- /// - Parameters:
- /// - service: The service whose state was updated.
- func serviceDidUpdateState(_ service: Service)
- /// Informs the delegate that the service has new settings that should be saved
- /// to Loop
- ///
- /// - Parameters:
- /// - settings: The settings object containing the new settings.
- func serviceHasNewTherapySettings(_ settings: TherapySettings)
- }
- public protocol Service: AnyObject {
- typealias RawStateValue = [String: Any]
- /// The unique identifier of this type of service.
- static var serviceIdentifier: String { get }
- /// The localized title of this type of service.
- static var localizedTitle: String { get }
- /// The delegate to notify of service updates.
- var serviceDelegate: ServiceDelegate? { get set }
- /// Initializes the service with the previously-serialized state.
- ///
- /// - Parameters:
- /// - rawState: The previously-serialized state of the service.
- init?(rawState: RawStateValue)
- /// The current, serializable state of the service.
- var rawState: RawStateValue { get }
- }
- public extension Service {
- var serviceIdentifier: String { return type(of: self).serviceIdentifier }
- var localizedTitle: String { return type(of: self).localizedTitle }
- }
|