@jalik/observer
Advanced tools
Comparing version 1.0.5 to 1.0.6
# Changelog | ||
## v1.0.6 | ||
- Updates dependencies | ||
## v1.0.5 | ||
@@ -4,0 +7,0 @@ - Removes unused devDependencies |
{ | ||
"name": "@jalik/observer", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "A library to observe events and trigger callbacks.", | ||
@@ -35,13 +35,14 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@babel/core": "^7.1.2", | ||
"@babel/preset-env": "^7.1.0", | ||
"ajv": "^6.5.4", | ||
"@babel/core": "^7.2.2", | ||
"@babel/preset-env": "^7.2.3", | ||
"acorn": "^6.0.5", | ||
"ajv": "^6.7.0", | ||
"babel-core": "^7.0.0-bridge.0", | ||
"del": "^3.0.0", | ||
"eslint": "^5.6.1", | ||
"eslint": "^5.12.0", | ||
"eslint-config-airbnb": "^17.1.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-jest": "^21.24.1", | ||
"eslint-plugin-jest": "^22.1.3", | ||
"eslint-plugin-jsx-a11y": "^6.1.2", | ||
"eslint-plugin-react": "^7.11.1", | ||
"eslint-plugin-react": "^7.12.4", | ||
"gulp": "^4.0.0", | ||
@@ -48,0 +49,0 @@ "gulp-babel": "^8.0.0", |
@@ -1,2 +0,2 @@ | ||
# Observer | ||
# @jalik/observer | ||
@@ -8,9 +8,9 @@ The classic observer design pattern. | ||
The Observer design pattern is a well known pattern to create reactive applications. | ||
For example, your can attach listeners to a form text field, then when the text field value changes, all listeners are notified of that change and thus can do something in response. | ||
For example, your can attach observers to a form text field, then when the text field value changes, all observers are notified of that change and thus can do something in response. | ||
**This library is tested with unit tests.** | ||
**This library has been unit tested.** | ||
## Attaching a listener and notify it | ||
## Attaching an observer and notify it | ||
The following code shows how to attach a listener and how to notify it of events. | ||
The following code shows how to attach an observer and how to notify it of events. | ||
@@ -27,10 +27,9 @@ ```js | ||
on(event, listener) { | ||
// Attach listener | ||
this.observer.attach(event, listener); | ||
on(event, observer) { | ||
// Attach observer | ||
this.observer.attach(event, observer); | ||
} | ||
say(words) { | ||
console.log(words); | ||
// Notify listeners | ||
// Notify observers | ||
this.observer.notify("say", words, new Date()); | ||
@@ -49,5 +48,5 @@ } | ||
## Detaching a listener | ||
## Detaching an observer | ||
In the case that you need to remove a previously attached listener, here is the code. | ||
In the case that you need to remove a previously attached observer, here is the code. | ||
@@ -54,0 +53,0 @@ ```js |
10622
16
82