react-services-injector
Advanced tools
Comparing version 0.0.1 to 0.0.2
34
index.js
@@ -14,12 +14,16 @@ class Injector { | ||
if (method === 'constructor' || method.indexOf('get') === 0) | ||
return; | ||
return; | ||
instance['__' + method] = instance[method]; | ||
instance['__' + method] = instance[method]; | ||
instance[method] = (...args) => { | ||
instance['__' + method].apply(instance, args); | ||
instance[method] = (...args) => { | ||
instance['__' + method].apply(instance, args); | ||
this.components.forEach(component => component.instance.forceUpdate()); | ||
this.components.forEach(component => component.instance.forceUpdate.call(component.instance)); | ||
}; | ||
}); | ||
instance.$update = () => { | ||
this.components.forEach(component => component.instance.forceUpdate.call(component.instance)); | ||
}; | ||
}); | ||
@@ -57,3 +61,3 @@ return instance; | ||
connect(component) { | ||
let key = null; | ||
var key = null; | ||
@@ -63,5 +67,10 @@ class ConnectedComponent extends component { | ||
super(props); | ||
} | ||
componentWillMount() { | ||
key = injector.connectInstance(this); | ||
this.services = Object.assign({}, injector.get()); | ||
key = injector.connectInstance(this); | ||
if (super.componentWillMount) | ||
super.componentWillMount(); | ||
} | ||
@@ -75,6 +84,2 @@ | ||
} | ||
static get name() { | ||
return component.name; | ||
} | ||
} | ||
@@ -89,6 +94,5 @@ | ||
if (typeof module !== 'undefined' && module.exports) { | ||
module.exports = injector; | ||
return; | ||
module.exports = {injector}; | ||
} else { | ||
exports.injector = injector; | ||
} | ||
} |
{ | ||
"name": "react-services-injector", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A library to create and use sigleton-services in your React application.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
22523
7
72
125