Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-observer-pattern

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-observer-pattern - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

2

package.json
{
"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
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc