Skip to content

Commit

Permalink
Improve scope of properties
Browse files Browse the repository at this point in the history
  • Loading branch information
yimajo committed Sep 7, 2024
1 parent e9a5271 commit b7ab6c1
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions app-ios/Sources/KMPClientLive/LiveKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,6 @@ import Foundation
import Firebase
import KMPClient

private var sessionsRepository: any SessionsRepository {
Container.shared.get(type: (any SessionsRepository).self)
}

private var staffRepository: any StaffRepository {
Container.shared.get(type: (any StaffRepository).self)
}

private var sponsorsRepository: any SponsorsRepository {
Container.shared.get(type: (any SponsorsRepository).self)
}

private var contributorRepository: any ContributorsRepository {
Container.shared.get(type: (any ContributorsRepository).self)
}

private var eventMapRepository: any EventMapRepository {
Container.shared.get(type: (any EventMapRepository).self)
}

private var profileCardRepository: any ProfileCardRepository {
Container.shared.get(type: (any ProfileCardRepository).self)
}

extension FirebaseAppClient: DependencyKey {
public static var liveValue: Self {
Self(
Expand All @@ -50,6 +26,10 @@ extension ContainerClient: DependencyKey {
}

extension TimetableClient: DependencyKey {
private static var sessionsRepository: any SessionsRepository {
Container.shared.get(type: (any SessionsRepository).self)
}

public static let liveValue: TimetableClient = .init(
streamTimetable: {
sessionsRepository.getTimetableStream().eraseToThrowingStream()
Expand All @@ -70,6 +50,10 @@ extension TimetableClient: DependencyKey {
}

extension StaffClient: DependencyKey {
private static var staffRepository: any StaffRepository {
Container.shared.get(type: (any StaffRepository).self)
}

public static let liveValue: StaffClient = .init(
streamStaffs: {
staffRepository
Expand All @@ -90,6 +74,10 @@ extension StaffClient: DependencyKey {
}

extension SponsorsClient: DependencyKey {
private static var sponsorsRepository: any SponsorsRepository {
Container.shared.get(type: (any SponsorsRepository).self)
}

public static let liveValue: SponsorsClient = .init(
streamSponsors: {
sponsorsRepository
Expand All @@ -115,6 +103,10 @@ extension SponsorsClient: DependencyKey {
}

extension ContributorClient: DependencyKey {
private static var contributorRepository: any ContributorsRepository {
Container.shared.get(type: (any ContributorsRepository).self)
}

public static let liveValue: ContributorClient = Self {
contributorRepository
.getContributorStream()
Expand All @@ -135,12 +127,20 @@ extension ContributorClient: DependencyKey {
}

extension EventMapClient: DependencyKey {
private static var eventMapRepository: any EventMapRepository {
Container.shared.get(type: (any EventMapRepository).self)
}

public static let liveValue: EventMapClient = .init {
eventMapRepository.getEventMapStream().eraseToThrowingStream()
}
}

extension ProfileCardClient: DependencyKey {
private static var profileCardRepository: any ProfileCardRepository {
Container.shared.get(type: (any ProfileCardRepository).self)
}

public static let liveValue: ProfileCardClient = .init { param in
try await profileCardRepository.save(
profileCard: .init(
Expand Down

0 comments on commit b7ab6c1

Please sign in to comment.