Skip to content

A lightweight and reusable Swift Package designed to simplify foundational development tasks in SwiftUI apps

Notifications You must be signed in to change notification settings

karthiikmk/OpenSourceCoreKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CoreKit

A description of this package.

DI

@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

About

A lightweight and reusable Swift Package designed to simplify foundational development tasks in SwiftUI apps

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages