-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.hbs
66 lines (48 loc) · 1.4 KB
/
README.hbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Spyo
Observe an object, check when it's change.
<a href="https://travis-ci.org/fabioricali/spyo" target="_blank"><img src="https://travis-ci.org/fabioricali/spyo.svg?branch=master" title="Build Status"/></a>
<a href="https://opensource.org/licenses/MIT" target="_blank"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" title="License: MIT"/></a>
## Installation
### Node.js
```
npm install spyo --save
```
### Browser
#### Local
```html
<script src="node_modules/spyo/dist/spyo.min.js"></script>
```
#### CDN unpkg
```html
<script src="https://unpkg.com/spyo/dist/spyo.min.js"></script>
```
## Example
```javascript
const Spyo = require('spyo');
const myObject = {
firstName: 'Mike',
lastName: 'Red'
};
const mySpy = new Spyo(myObject);
myObject.firstName = 'John';
mySpy.onChange((different) => {
console.log('is different:', different);
});
```
## Use provider function
```javascript
const mySpy = new Spyo(() => {
return Math.random();
});
mySpy.onChange((different) => {
console.log('is different:', different);
});
```
## API
{{>main}}
## Changelog
You can view the changelog <a target="_blank" href="https://github.com/fabioricali/spyo/blob/master/CHANGELOG.md">here</a>
## License
Spyo is open-sourced software licensed under the <a target="_blank" href="http://opensource.org/licenses/MIT">MIT license</a>
## Author
<a target="_blank" href="http://rica.li">Fabio Ricali</a>