ts-observer-pattern
Advanced tools
Comparing version 1.0.1 to 2.0.0
{ | ||
"name": "ts-observer-pattern", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"description": "Interfaces to help working with the Observer Pattern", | ||
@@ -5,0 +5,0 @@ "main": "index.ts", |
import { Observer } from "./Observer" | ||
export interface Subject | ||
export abstract class Subject | ||
{ | ||
attach(Observer: Observer): this | ||
detach(Observer: Observer): this | ||
notify(data: any): this | ||
protected observers: Observer[] | ||
public attach(observer: Observer): this | ||
{ | ||
this.observers.push(observer) | ||
return this | ||
} | ||
public detach(observer: Observer): this | ||
{ | ||
this.observers = this.observers.filter(item => item !== observer) | ||
return this | ||
} | ||
public notify(data: any): this | ||
{ | ||
this.observers.forEach(observer => observer.update(data)) | ||
return this | ||
} | ||
} |
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
1364
26