uber/needle

The property is not passed from the parent to the child

gnori-zon opened this issue · 1 comments

final class Root: BootstrapComponent {
   var child: Child {
      shared { Child(parent: self) }
   }
    var food: Food {
       shared { Food(parent: self) }
    }
}

final class Food: Component<EmptyDependency> {

   var foodVC: FoodVC {
       FoodVC()
   }
}

protocol MyDependency: Dependency {
    var food: Food { get }
}

final class Child: Component<MyDependency> {

    var foodContainer: FoodContainer {
       FoodContainer(vc: dependency.food.foodVC)
    }
}

It should be compiled from the instructions, but it is not.
Outputs: Could not find a provider for (vc: FoodVC)...
Please help me understand what I'm doing wrong.

upd: I dug around and found the problem, it is necessary to change the access modifier of the property in parent

THIS IS COMPILED

final class Root: BootstrapComponent {
   var child: Child {
      shared { Child(parent: self) }
   }
    public var food: Food {
       shared { Food(parent: self) }
    }
}

final class Food: Component<EmptyDependency> {

   var foodVC: FoodVC {
       FoodVC()
   }
}

protocol MyDependency: Dependency {
    var food: Food { get }
}

final class Child: Component<MyDependency> {

    var foodContainer: FoodContainer {
       FoodContainer(vc: dependency.food.foodVC)
    }
}