BasalProfileEditorDataFlow.swift 783 B

1234567891011121314151617181920212223242526272829303132
  1. import Combine
  2. import Foundation
  3. enum BasalProfileEditor {
  4. enum Config {}
  5. class Item: Identifiable, Hashable, Equatable {
  6. let id = UUID()
  7. var rateIndex = 0
  8. var timeIndex = 0
  9. init(rateIndex: Int, timeIndex: Int) {
  10. self.rateIndex = rateIndex
  11. self.timeIndex = timeIndex
  12. }
  13. static func == (lhs: Item, rhs: Item) -> Bool {
  14. lhs.timeIndex == rhs.timeIndex
  15. }
  16. func hash(into hasher: inout Hasher) {
  17. hasher.combine(timeIndex)
  18. }
  19. }
  20. }
  21. protocol BasalProfileEditorProvider: Provider {
  22. var profile: [BasalProfileEntry] { get }
  23. var supportedBasalRates: [Double]? { get }
  24. func saveProfile(_ profile: [BasalProfileEntry]) -> AnyPublisher<Void, Error>
  25. }