Skip to content

Commit

Permalink
Merge pull request #991 from yimajo/improve_property_scope
Browse files Browse the repository at this point in the history
Improve scope of properties in KMPClientLive
  • Loading branch information
ry-itto committed Sep 10, 2024
2 parents a8e57b3 + b7ab6c1 commit bd299c7
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 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 @@ -104,7 +92,7 @@ extension SponsorsClient: DependencyKey {
return Model.Sponsor(
id: $0.name,
logo: URL(string: $0.logo)!,
link: URL(string: $0.link)!,
link: URL(string: $0.link)!,
plan: plan
)
}
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,6 +127,10 @@ 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()
Expand Down Expand Up @@ -173,6 +169,10 @@ extension EventMapClient: DependencyKey {
}

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 bd299c7

Please sign in to comment.