Closed akitchen closed 9 years ago
I think this has also come up once or twice in the Toronto office. It would be handy to be able to remove bindings.
I'm now running into this situation as well. Are there any alternatives available?
I'll add that the root problem isn't overriding bindings. The problem is that binding a class key to the class itself is not currently supported:
context(@"when the key is a class which is bound to the same class", ^{
it(@"should build the class without infinite recursion", ^{
[injector bind:[Address class] toClass:[Address class]];
id address = [injector getInstance:[Address class]];
expect(address).to(be_instance_of([Address class]));
});
});
Thanks for tracking this down. Do we know whether this is easily fixed?
On Tue, Sep 8, 2015 at 8:02 PM, Brian Croom notifications@github.com wrote:
I'll add that the root problem isn't overriding bindings. The problem is that binding a class key to the class itself is not currently supported:
context(@"when the key is a class which is bound to the same class", ^{ it(@"should build the class without infinite recursion", ^{ [injector bind:[Address class] toClass:[Address class]]; id address = [injector getInstance:[Address class]]; expect(address).to(be_instance_of([Address class])); }); });
— Reply to this email directly or view it on GitHub https://github.com/jbsf/blindside/issues/23#issuecomment-138671265.
We found ourselves in a situation where we wanted to override a binding; the key was a class which had been previously bound to an instance. The world imploded.
Alternatively, is there a recommended way to remove a binding to restore the default behavior? This came up in a testing scenario.