@@ -14,9 +14,6 @@ import { MemoryCache } from './services/memorycache';
1414import { IService , ISchema , IResource , ICollection , IExecParams , ICache , IParamsCollection , IParamsResource } from './interfaces' ;
1515
1616export class Service extends ParentResourceService implements IService {
17- public is_new = true ;
18- public is_loading = false ;
19- public is_saving = false ;
2017 public schema : ISchema ;
2118 public memorycache : ICache ;
2219 public type : string ;
@@ -34,6 +31,7 @@ export class Service extends ParentResourceService implements IService {
3431 }
3532 // only when service is registered, not cloned object
3633 this . memorycache = new MemoryCache ( ) ;
34+ this . schema = angular . extend ( { } , Base . Schema , this . schema ) ;
3735 return Core . Me . _register ( this ) ;
3836 }
3937
@@ -53,27 +51,20 @@ export class Service extends ParentResourceService implements IService {
5351 }
5452
5553 public get < T extends IResource > ( id , params ?: IParamsResource | Function , fc_success ?: Function , fc_error ?: Function ) : T {
56- // return this.__exec({ id, params, fc_success, fc_error, 'get' });
5754 return this . __exec ( { id : id , params : params , fc_success : fc_success , fc_error : fc_error , exec_type : 'get' } ) ;
5855 }
5956
6057 public delete ( id : string , params ?: Object | Function , fc_success ?: Function , fc_error ?: Function ) : void {
61- // this.__exec(id, params, fc_success, fc_error, 'delete');
6258 return this . __exec ( { id : id , params : params , fc_success : fc_success , fc_error : fc_error , exec_type : 'delete' } ) ;
6359 }
6460
6561 public all ( params ?: IParamsCollection | Function , fc_success ?: Function , fc_error ?: Function ) : ICollection {
6662 return this . __exec ( { id : null , params : params , fc_success : fc_success , fc_error : fc_error , exec_type : 'all' } ) ;
6763 }
6864
69- /**
70- This method sort params for all(), get(), delete() and save()
71- */
7265 protected __exec ( exec_params : IExecParams ) : any {
7366 super . __exec ( exec_params ) ;
7467
75- this . schema = angular . extend ( { } , Base . Schema , this . schema ) ;
76-
7768 switch ( exec_params . exec_type ) {
7869 case 'get' :
7970 return this . _get ( exec_params . id , exec_params . params , exec_params . fc_success , exec_params . fc_error ) ;
@@ -265,8 +256,6 @@ export class Service extends ParentResourceService implements IService {
265256 . delete ( path . get ( ) )
266257 . then (
267258 success => {
268- // we don't use more temporary_collection
269- // delete this.tempororay_collection[id];
270259 this . getService ( ) . memorycache . removeResource ( id ) ;
271260 this . runFc ( fc_success , success ) ;
272261 } ,
@@ -279,11 +268,11 @@ export class Service extends ParentResourceService implements IService {
279268 /**
280269 @return This resource like a service
281270 **/
282- public getService ( ) {
271+ public getService ( ) : IService {
283272 return Converter . getService ( this . type ) ;
284273 }
285274
286- public clearMemoryCache ( ) {
275+ public clearMemoryCache ( ) : boolean {
287276 return this . getService ( ) . memorycache . clearAllCollections ( ) ;
288277 }
289278}
0 commit comments