Comparing version 2.5.0 to 2.6.0
@@ -15,3 +15,3 @@ { | ||
], | ||
"version": "2.5.0", | ||
"version": "2.6.0", | ||
"description": "Powerful event emitter", | ||
@@ -32,21 +32,21 @@ "keywords": [ | ||
"dependencies": { | ||
"@babel/runtime": "7.0.0" | ||
"@babel/runtime": "7.1.2" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "7.0.0", | ||
"@babel/core": "7.0.0", | ||
"@babel/plugin-proposal-class-properties": "7.0.0", | ||
"@babel/cli": "7.1.2", | ||
"@babel/core": "7.1.2", | ||
"@babel/plugin-proposal-class-properties": "7.1.0", | ||
"@babel/plugin-proposal-object-rest-spread": "7.0.0", | ||
"@babel/plugin-transform-runtime": "7.0.0", | ||
"@babel/preset-env": "7.0.0", | ||
"babel-core": "^7.0.0-bridge.0", | ||
"babel-eslint": "^8.2.6", | ||
"eslint": "^5.2.0", | ||
"eslint-config-prettier": "^2.9.0", | ||
"eslint-plugin-prettier": "^2.6.2", | ||
"eslint-plugin-react": "^7.10.0", | ||
"husky": "^1.0.0-rc.13", | ||
"@babel/plugin-transform-runtime": "7.1.0", | ||
"@babel/preset-env": "7.1.0", | ||
"babel-core": "^6.26.3", | ||
"babel-eslint": "^10.0.1", | ||
"eslint": "^5.8.0", | ||
"eslint-config-prettier": "^3.1.0", | ||
"eslint-plugin-prettier": "^3.0.0", | ||
"eslint-plugin-react": "^7.11.1", | ||
"husky": "^1.1.2", | ||
"jest": "23.6.0", | ||
"lint-staged": "^7.2.0", | ||
"prettier": "^1.14.0", | ||
"lint-staged": "^8.0.3", | ||
"prettier": "^1.14.3", | ||
"rimraf": "^2.6.2" | ||
@@ -53,0 +53,0 @@ }, |
@@ -23,5 +23,7 @@ # dot-event | ||
const events = dotEvent() | ||
events.on(() => { | ||
/* do something */ | ||
}) | ||
events.emit() | ||
@@ -34,6 +36,7 @@ ``` | ||
events.on(async () => {}) | ||
await events.emit() | ||
``` | ||
The emitter returns a promise that waits for listeners to resolve. | ||
The emitter returns a promise that waits for all listeners to resolve concurrently. | ||
@@ -46,2 +49,3 @@ ## Dot-props | ||
events.on("emit.hello.world", () => {}) | ||
events.emit("hello.world") // emits | ||
@@ -55,2 +59,3 @@ events.emit() // doesn't emit | ||
events.onAny("emit.hello", () => {}) | ||
events.emit("hello") // emits | ||
@@ -63,12 +68,13 @@ events.emit("hello.world") // emits | ||
Why do we have to specify `emit` before the the prop in this example? | ||
You might be confused why this subscription prop is `emit.hello`: | ||
```js | ||
events.on("emit.hello", () => {}) | ||
events.emit("hello") | ||
events.emit("hello") // emits | ||
``` | ||
Because `emit` is an "operation", and you can have more than one. | ||
This is because `emit` is an "operation", and you can have more than one. | ||
First, define the operation: | ||
First, define your custom operation: | ||
@@ -83,7 +89,6 @@ ```js | ||
events.on("create", () => {}) | ||
events.create() // emits the create operation | ||
``` | ||
Operation functions take the same arguments and behave similar to `emit`. | ||
## Subscription listener argument | ||
@@ -97,12 +102,6 @@ | ||
}) | ||
events.emit({ hello: "world" }) | ||
``` | ||
Or use `withOptions` on the subscriber: | ||
```js | ||
events.withOptions({ hello: "world" }).on(({ hello }) => {}) | ||
events.emit() | ||
``` | ||
The listener argument also contains an `event` property with extra information, such as the emitter arguments: | ||
@@ -112,5 +111,6 @@ | ||
events.on(({ event }) => { | ||
event.args // [123, true] | ||
/* event.args === [true] */ | ||
}) | ||
events.emit(123, true) | ||
events.emit(true) | ||
``` | ||
@@ -132,2 +132,3 @@ | ||
}) | ||
events.emit() | ||
@@ -144,6 +145,6 @@ ``` | ||
events.onAny(() => {}) | ||
events.emit() // emits | ||
events.emit("hello") // emits | ||
events.emit("hello.world") // emits | ||
events.create() // emits | ||
``` | ||
@@ -155,2 +156,3 @@ | ||
events.onAny("emit.hello", () => {}) | ||
events.emit("hello") // emits | ||
@@ -167,3 +169,5 @@ events.emit("hello.world") // emits | ||
events.emit() | ||
events.onEmitted(() => {}) // emits immediately | ||
events.emit() // emits | ||
@@ -178,3 +182,5 @@ ``` | ||
events.emit("hello.world") | ||
events.onAnyEmitted("emit.hello", () => {}) // emits immediately | ||
events.emit("hello.world") // emits | ||
@@ -188,2 +194,3 @@ events.emit() // doesn't emit | ||
events.once(() => {}) | ||
events.emit() // emits | ||
@@ -199,3 +206,5 @@ events.emit() // doesn't emit | ||
events.emit() | ||
events.onceEmitted(() => {}) // emits immediately | ||
events.emit() // doesn't emit | ||
@@ -210,2 +219,3 @@ ``` | ||
events.onceAny("emit.hello", () => {}) | ||
events.emit("hello.world") // emits | ||
@@ -221,3 +231,5 @@ events.emit("hello.world") // doesn't emit | ||
events.emit("hello.world") | ||
events.onceAnyEmitted("emit.hello", () => {}) // emits immediately | ||
events.emit("hello.world") // doesn't emit | ||
@@ -224,0 +236,0 @@ ``` |
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
248
116690
+ Added@babel/runtime@7.1.2(transitive)
- Removed@babel/runtime@7.0.0(transitive)
Updated@babel/runtime@7.1.2