-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCodeBehindDependencies.swift
61 lines (55 loc) · 1.58 KB
/
CodeBehindDependencies.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// CodeBehindDependencies.swift
// PatchDay
//
// Created by Juliya Smith on 11/20/19.
import Foundation
import PDKit
class CodeBehindDependencies<T>: DependenciesProtocol {
let sdk: PatchDataSDK?
var tabs: TabReflective?
let notifications: NotificationScheduling?
var alerts: AlertProducing?
let nav: NavigationHandling?
let badge: PDBadgeReflective?
let widget: PDWidgetProtocol?
lazy var log = PDLog<CodeBehindDependencies>()
lazy var contextClass = String(describing: T.self)
init(
sdk: PatchDataSDK?,
tabs: TabReflective?,
notifications: NotificationScheduling?,
alerts: AlertProducing?,
nav: NavigationHandling?,
badge: PDBadgeReflective?,
widget: PDWidgetProtocol?
) {
self.sdk = sdk
self.tabs = tabs
self.notifications = notifications
self.alerts = alerts
self.nav = nav
self.badge = badge
self.widget = widget
}
init() {
if let app = AppDelegate.current {
self.sdk = app.sdk
self.tabs = app.tabs
self.notifications = app.notifications
self.alerts = app.alerts
self.nav = app.nav
self.badge = app.badge
self.widget = app.widget
} else {
self.sdk = nil
self.tabs = nil
self.notifications = nil
self.alerts = nil
self.nav = nil
self.badge = nil
self.widget = nil
log.error("App is not yet initialized before \(contextClass)")
}
}
}