diff --git a/README.md b/README.md index 573e669..4918e10 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,44 @@ # CoreKit A description of this package. + +## DI + +```Swift + +@main +struct YourApp: App { + init() { + // Put your DI setup here. + } +} + +// SetupDI +SwiftDI.shared.setup( + assemblies: [ + ServiceAssembly(), + ViewModelAssembly() + ], + inContainer: Container() +) + +class ServiceAssembly: Assembly { + func assemble(container: Container) { + // put you reusable service here + } +} + +class ViewModelAssembly: Assembly { + func assemble(container: Container) { + // Put you view models here + container.autoregister(SomeViewModel.self, initializer: SomeViewModel.init) + container.register(SomeViewModel.self) { r in + // initialization goes here + return SomeViewMode() + } + } +} + +@Inject - Use this inside viewModel for object lookup +@ObservedInject - Use this in swiftUI for the object lookup +``` diff --git a/Sources/CoreKit/Others/FetchState.swift b/Sources/CoreKit/Others/FetchState.swift index 38a2819..f74d912 100644 --- a/Sources/CoreKit/Others/FetchState.swift +++ b/Sources/CoreKit/Others/FetchState.swift @@ -14,3 +14,14 @@ public enum FetchState { self == .fetching } } + +public enum ViewState { + /// The view is currently loading data. + case loading + /// The view has loaded data, but the list is empty. + case empty + /// The view failed to load data. + case failed + /// The view has successfully loaded data. + case loaded +}