@semantic-ui/reactivity
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "@semantic-ui/reactivity", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"type": "module", | ||
@@ -9,2 +9,10 @@ "main": "src/index.js", | ||
"license": "ISC", | ||
"scripts": { | ||
"publish": "wireit" | ||
}, | ||
"wireit": { | ||
"publish": { | ||
"command": "npm publish" | ||
} | ||
}, | ||
"dependencies": { | ||
@@ -11,0 +19,0 @@ "@semantic-ui/utils": "^0.0.1" |
@@ -24,2 +24,3 @@ # @semantic-ui/reactivity | ||
- [Helper Functions](#helper-functions) | ||
* [Number Helpers](#numbers) | ||
* [Array Mutation Helpers](#array-mutation-helpers) | ||
@@ -361,2 +362,37 @@ * [Array of Objects](#array-of-objects) | ||
### Numbers | ||
`ReactiveVar` includes a couple helpers numbers | ||
```javascript | ||
let count = new ReactiveVar(0); | ||
count.increment(); // set to 1 | ||
``` | ||
```javascript | ||
let count = new ReactiveVar(0); | ||
count.increment(2); // set to 2 | ||
``` | ||
```javascript | ||
let count = new ReactiveVar(2); | ||
count.decrement(); // set to 1 | ||
``` | ||
```javascript | ||
let count = new ReactiveVar(0); | ||
count.decrement(2); // set to 1 | ||
``` | ||
### Date | ||
`ReactiveVar` includes a helper to make dates asier | ||
```javascript | ||
let date = new ReactiveVar(new Date()); // initializes as now | ||
setTimeout(() => { | ||
date.now(); // now 1 second later | ||
}, 1000); | ||
``` | ||
### Array Mutation Helpers | ||
@@ -368,15 +404,15 @@ | ||
let items = new ReactiveVar([0,1,2]); | ||
tpl.items.removeIndex(1); // outputs 0, 2 | ||
items.removeIndex(1); // outputs 0, 2 | ||
``` | ||
```javascript | ||
let items = new ReactiveVar([0,2,2]); | ||
tpl.items.setIndex(1); // outputs 0, 1, 2 | ||
items.setIndex(1); // outputs 0, 1, 2 | ||
``` | ||
```javascript | ||
let items = new ReactiveVar([0,1,2]); | ||
tpl.items.unshift(); // outputs 1, 2 | ||
items.unshift(); // outputs 1, 2 | ||
``` | ||
```javascript | ||
let items = new ReactiveVar([0,1,2]); | ||
tpl.items.push(3); // outputs 0, 1, 2, 3 | ||
items.push(3); // outputs 0, 1, 2, 3 | ||
``` | ||
@@ -383,0 +419,0 @@ |
@@ -1,4 +0,4 @@ | ||
import { ReactiveVar } from './reactive-var'; | ||
import { Reaction } from './reaction'; | ||
import { Dependency } from './dependency'; | ||
import { ReactiveVar } from './reactive-var.js'; | ||
import { Reaction } from './reaction.js'; | ||
import { Dependency } from './dependency.js'; | ||
@@ -5,0 +5,0 @@ export { |
@@ -117,2 +117,13 @@ import { clone, isObject, isEqual, wrapFunction, findIndex, unique, isNumber } from '@semantic-ui/utils'; | ||
increment(amount = 1) { | ||
return this.set(this.value + amount); | ||
} | ||
decrement(amount = 1) { | ||
return this.set(this.value - amount); | ||
} | ||
now() { | ||
return this.set(new Date()); | ||
} | ||
getIDs(item) { | ||
@@ -119,0 +130,0 @@ if(isObject(item)) { |
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
40137
824
454