3.0.13 • Published 3 years ago

base-model-wrap v3.0.13

Weekly downloads
9
License
MIT
Repository
github
Last release
3 years ago

base-model-wrap

Purpose of this project is to provide nice way of using javascript class object inside your framework.

The reason you would like to to this object instead of raw object from server is that when some changes happen to your object on the server side you will force to just change you class object instead every raw object in your templates.

This is really usefull in angular js/2/4 and react apps.

Example

interface RawData {
    fatPercentage: number;
    bodyWeight: number;
}

class Calories extends BaseModelWrap<RawData> {
		
	constructor( data:RawData ) {
		super(data)
	}
	
	get fat() {
		return this.data.fatPercentage
	}	

}

now in your component class:

...
calalories = new Calories({ fatPercentage: 12, bodyWeight: 87  });

// you can clone you object
calories2 = calories.clone()
...

and inside template:

...
	<span> Fat {{ calories.fat }} </span> 
...

Models inside models

interface RawData {
    fatPercentage: number;
    bodyWeight: number;
}

class Calories extends BaseModelWrap<RawData> {
		
	constructor( data:RawData ) {
		super(data)
	}
	
	get fat() {
		return this.data.fatPercentage
	}	

}
3.0.13

3 years ago

3.0.10

3 years ago

3.0.11

3 years ago

3.0.9

4 years ago

3.0.4

4 years ago

3.0.1

4 years ago

3.0.8

4 years ago

3.0.7

4 years ago

3.0.6

4 years ago

3.0.5

4 years ago

2.0.7

7 years ago

2.0.6

7 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.1

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago