0.3.0 • Published 6 months ago

@nbottarini/observable v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

npm License: MIT CI Status

Observable-Js

Tiny Observable pattern implementation for creating observable properties

Installation

Npm:

$ npm install --save @nbottarini/observable

Yarn:

$ yarn add @nbottarini/observable

Usage

View1.ts:

export class View1 {
    public readonly buttonClicked = new Observable<ClickEvent>()
    public readonly textChanged = new Observable<TextChangedEvent>()
    
    // Do something internally to handle UI events 
    
    private handleButtonClick(e: ClickEvent) {
        this.buttonClicked.notify(e)
    }
}

View2.ts:

export class View2 {
    private sampleView: View1
    
    constructor() {
        this.sampleView = new View1()
        this.sampleView.buttonClicked.subscribe(this, this.onSampleViewButtonClicked)
    }

    onSampleViewButtonClicked(e: ClickEvent) {
        
    }
}
0.3.0

6 months ago

0.2.1

9 months ago

0.2.2

9 months ago

0.2.0

12 months ago