react-services-injector
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "react-services-injector", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A library to create and use sigleton-services in your React application.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
React Services Injector | ||
=================== | ||
Got tired with Redux? Really hate that ACTION_THAT_DOES_SOME_ACTION: "ACTION_THAT_DOES_SOME_ACTION"? Or maybe you are used to be an Angular-developer? So then you definitely should try some services in React! | ||
Got tired with Redux? Really hate that `ACTION_THAT_DOES_SOME_ACTION: "ACTION_THAT_DOES_SOME_ACTION"`? Or maybe you are used to be an Angular-developer? So then you definitely should try some services in React! | ||
@@ -29,4 +29,3 @@ Installation | ||
return this.products.filter(product => { | ||
return (product.name || '') | ||
.toLowerCase() | ||
return (product.name || '').toLowerCase() | ||
.indexOf(this.filter.toLowerCase()) === 0; | ||
@@ -75,14 +74,14 @@ }) || []; | ||
this.addRandomProduct = this.addRandomProduct.bind(this); | ||
this.addRandomProduct = this.addRandomProduct.bind(this); | ||
} | ||
addRandomProduct() { | ||
addRandomProduct() { | ||
this.services.storage.addProduct({ | ||
name: 'Test product', | ||
price: Math.floor(Math.random() * 250) + 50 | ||
name: 'Test product', | ||
price: Math.floor(Math.random() * 250) + 50 | ||
}); | ||
} | ||
} | ||
render() { | ||
let {storage} = this.services; | ||
let {storage} = this.services; | ||
@@ -92,3 +91,3 @@ return ( | ||
{storage.getFiltered().map((product, index) => | ||
<Product key={index} data={product} /> | ||
<Product key={index} data={product} /> | ||
)} | ||
@@ -109,21 +108,21 @@ | ||
=== | ||
####Singletons | ||
#### Singletons | ||
Services are singletons, so you can use your service in multiple components with the same data. | ||
####Asynchronous actions | ||
#### Asynchronous actions | ||
If you want to do some asynchronous stuff if your service, please use `this.$update()` after it is done (remember `$scope.$apply()`, huh?) For example: | ||
```javascript | ||
addProduct({name, price}) { | ||
setTimeout(() => { | ||
this.products.push({category, name, price, stocked}); | ||
setTimeout(() => { | ||
this.products.push({category, name, price, stocked}); | ||
this.$update(); //here is it | ||
}, 200); | ||
this.$update(); //here is it | ||
}, 200); | ||
} | ||
``` | ||
####Only ES6 classes | ||
#### Only ES6 classes | ||
It is already 2017, right? Please, use ES6 classes instead of `React.createComponent` (especially as even React says that method is deprecated). Also, the library won't connect your functional components -- create a class if you want to use services there. | ||
####Troubleshooting | ||
#### Troubleshooting | ||
Please, feel free to create an issue any time if you found a bug or unexpected behavior. | ||
Feature requests are pretty much acceptable too. | ||
Feature requests are pretty much acceptable too. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8
19344