1.0.1 • Published 1 year ago

@bryanhannes/typed-view-model v1.0.1

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

Typed view model

This is a small library to help you create typed view models.

Installation

npm install --save @bryanhannes/typed-view-model

How to use

interface PageViewModel {
    name: string;
    number: number;
    stringArray: string[];
}

const name$$ = new Subject<string>();
const number$$ = new Subject<number>();
const stringArray$$ = new Subject<string[]>();

const vm$ = vm<PageViewModel>({
    name: {observable: name$$, initialValue: 'John Snow'},
    number: {observable: number$$, initialValue: 5000},
    stringArray: {observable: stringArray$$, initialValue: ['a', 'b', 'c']},
});