Comments (5)
I think the way to approach this is to have a unified API offered by JSObjection allowing registration and bindings which is then used by modules as a convenient way of grouping these decisions/actions in one place. In fact I think it would greatly simplify the API if the idea of registering and the idea of bindings were unified as they are essentially the same thing to someone using the API. Anything that can be done in a module should be able to be achieved outside the module.
from objection.
I don't think I'll move those kind of mechanisms into JSObjection since I set it up to act as class registry for Injectors to use for creating dependencies.
The responsibilities are as follows:
- JSObjection is a global class registry
- JSObjectionInjectors provide objects using the global class registry but do not manipulate global state
- JSObjectionModule defines new bindings that a Injector uses when the class registry is not enough
- JSObjectionEntry defines how an object is brought into existence
Putting those responsibilities in one place violates single responsibility principle. The perceived convenience is a red herring to me.
from objection.
True. And I'm probably just being myopic, but I'm not suggesting you merge any of those classes or violate the SRP. I suppose I'm saying two things:
- I shouldn't have to create a module in order to ask for a Protocol dependency to be satisfied with a class instance. A module is great for grouping a set of related decisions together, but it is overkill for asking for a single dependency to be satisfied and adds unnecessary complexity in these cases.
- I would like a unified API that offers the following available to me from inside a module or not (These are taken from an adapter I am using in front of Objection at the moment):
-(void)whenAskedForClassSupplyClass:(Class)clazz;
-(void)whenAskedForClass:(Class)clazz supplyInstance:(id)instance;
-(void)whenAskedForProtocol:(Protocol *)protocol supplyInstance:(id)instance;
-(void)whenAskedForProtocol:(Protocol *)protocol supplyClass:(Class)clazz;
-(void)mapSingleton:(Class)clazz;
-(void)whenAskedForProtocol:(id)protocol supplySingletonOfClass:(Class)clazz;
from objection.
It appears that you are asking for another registry mechanism for protocols. The reason I've avoided that is that protocols are used sparingly in Objective-C outside of the delegate pattern.
from objection.
For reference,
JIT bindings for Guice does this. http://code.google.com/p/google-guice/wiki/JustInTimeBindings.
from objection.
Related Issues (20)
- Support setting properties of non-object types
- Does objection inject dependencies automatically on creation? HOT 2
- frida ๅฝไปค้่ฏฏ
- Compatibility with Swift HOT 3
- Reseting Objection's global context storage caches HOT 2
- Injection at Initialization HOT 3
- Inject property declared in a category.
- Sharing singleton scope when deriving a new injector HOT 1
- Ability to specify override objects HOT 5
- @objection_initializer not passing arguments HOT 2
- Injecting object with protocol and superclass
- about sample? HOT 1
- why not use modern objective-c
- Why "JSObjectionModule.m" file line fifth to write "#import <Objection/JSObjectionProviderEntry.h>", but not "#import "JSObjectionProviderEntry.h"".
- why JSObjectionEntry's injector property is "assign" not "weak"?
- Passing nil arguments for get objection object HOT 7
- inScope:JSObjectionScopeSingleton doesn't work since Cocoapods version 1.6 HOT 19
- Build is broken on XCode 6.4 HOT 4
- Getting a reference to the JSObjectionInjector which created an object? HOT 2
- Undeclared selector warnings
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from objection.