rails-delegate
Advanced tools
Comparing version 0.4.0 to 0.4.1
{ | ||
"name": "rails-delegate", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "A simple helper to implement the delegation pattern in JavaScript code bases", | ||
@@ -5,0 +5,0 @@ "main": "lib/rails-delegate.js", |
@@ -15,2 +15,4 @@ # Delegation Pattern for JavaScript | ||
## Delegating methods | ||
```javascript | ||
@@ -38,3 +40,18 @@ delegate = require('rails-delegate'); | ||
## Delegating Events | ||
You can also forward events emitted by wrapped classes. | ||
```javascript | ||
function Car() { | ||
this.engine = new Engine(); | ||
delegateEvents('starting', 'stopping', { from: this.engine, to: this }); | ||
}; | ||
``` | ||
Now if `myCar.engine` emits a starting `starting` event, | ||
`myCar` also emits that event. | ||
## Alternatives | ||
@@ -41,0 +58,0 @@ |
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
6247
63