Skip to content

Instantly share code, notes, and snippets.

emoonadev / CoreDependency.kt
Created Jul 27, 2020
Super simple dependency injection
View CoreDependency.kt
import kotlin.reflect.KProperty
typealias DependencyContainer = (factory: Container) -> Unit
interface Resolver {
fun <T> resolve(type: Class<T>): T
fun init(apply: DependencyContainer)
inline fun <reified T> Resolver.resolve() = resolve(
emoonadev / CoreDependency.swift
Last active Jul 27, 2020
Super simple IOC pattern using property wrapper
View CoreDependency.swift
import SwiftUI
protocol Resolver {
func resolve<T>() -> T
struct DependencyInjector {
enum InstanceType {
case single, new