-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
Problem
Injection does not work for multiple class instances that need unique config:
class Magician {
constructor(@inject('equipment') private inventory: {}) {
}
}
app.bind('equipment).to({
weapon: superPowerfulArtifact,
});
app.bind('hero').toClass(Magician);
app.bind('villain').toClass(Magician);
// now the villain can access the superPowerfulArtifact! Oh noes!Acceptance Criteria
Find a way to override the existing injection (if any) on a per-binding level so that different instances can be configured easily, but with injection still at work.
class Magician {
constructor(@inject('equipment') private inventory: {}) {
}
}
app.bind('equipment).to({
weapon: squirtGun,
});
app.bind('hero').toClass(Magician).with(() => {
equipment: {
weapon: superPowerfulArtifact,
}
});
app.bind('villain').toClass(Magician);
// Only the hero gets the superPowerfulArtifact now! Yay!See #631 for previous discussion on the topic