Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clearer documentation about runtime arguments #70

Closed
yoichitgy opened this issue Mar 22, 2016 · 1 comment
Closed

Add clearer documentation about runtime arguments #70

yoichitgy opened this issue Mar 22, 2016 · 1 comment

Comments

@yoichitgy
Copy link
Member

Add documentation as mentioned by @brunopinheiro in Issue #45.

class PetOwner {
   var pet: AnimalType
}

container.register(PetOwner.self) { (_: ResolverType, pet: AnimalType) in
   var petOwner = PetOwner()
   petOwner.pet = pet
   return petOwner
}

var cat = Cat(name: "Bilbo")

// Won't work, since we don't have any Registration Key matching [PetOwner, (Cat) -> PetOwner]
var petOwner = container.resolve(PetOwner.self, argument: cat)!

// This is the correct Registration Key [PetOwner, (AnimalType) -> PertOwner]
var petOwner = container.resolve(PetOwner.self, argument: cat as AnimalType)!
@yoichitgy
Copy link
Member Author

Add the documentation by 5b2d047.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant