@@ -26,19 +26,19 @@ export class Service extends ParentResourceService implements IService {
2626 @return true if the resource don't exist and registered ok
2727 **/
2828 public register ( ) : boolean {
29- if ( Core . Me === null ) {
29+ if ( Core . me === null ) {
3030 throw 'Error: you are trying register --> ' + this . type + ' <-- before inject JsonapiCore somewhere, almost one time.' ;
3131 }
3232 // only when service is registered, not cloned object
3333 this . memorycache = new MemoryCache ( ) ;
3434 this . schema = angular . extend ( { } , Base . Schema , this . schema ) ;
35- return Core . Me . _register ( this ) ;
35+ return Core . me . _register ( this ) ;
3636 }
3737
38- public new < T extends IResource > ( id : string = '' ) : T {
38+ public new < T extends IResource > ( ) : T {
3939 let resource : IResource = new Resource ( ) ;
4040 resource . type = this . type ;
41- resource . id = id ;
41+ resource . reset ( ) ;
4242 return < T > resource ;
4343 }
4444
@@ -50,18 +50,18 @@ export class Service extends ParentResourceService implements IService {
5050 }
5151
5252 public get < T extends IResource > ( id , params ?: IParamsResource | Function , fc_success ?: Function , fc_error ?: Function ) : T {
53- return this . __exec ( { id : id , params : params , fc_success : fc_success , fc_error : fc_error , exec_type : 'get' } ) ;
53+ return < T > this . __exec ( { id : id , params : params , fc_success : fc_success , fc_error : fc_error , exec_type : 'get' } ) ;
5454 }
5555
5656 public delete ( id : string , params ?: Object | Function , fc_success ?: Function , fc_error ?: Function ) : void {
57- return this . __exec ( { id : id , params : params , fc_success : fc_success , fc_error : fc_error , exec_type : 'delete' } ) ;
57+ return < void > this . __exec ( { id : id , params : params , fc_success : fc_success , fc_error : fc_error , exec_type : 'delete' } ) ;
5858 }
5959
6060 public all ( params ?: IParamsCollection | Function , fc_success ?: Function , fc_error ?: Function ) : ICollection {
61- return this . __exec ( { id : null , params : params , fc_success : fc_success , fc_error : fc_error , exec_type : 'all' } ) ;
61+ return < ICollection > this . __exec ( { id : null , params : params , fc_success : fc_success , fc_error : fc_error , exec_type : 'all' } ) ;
6262 }
6363
64- protected __exec ( exec_params : IExecParams ) : any {
64+ protected __exec ( exec_params : IExecParams ) : IResource | ICollection | void {
6565 super . __exec ( exec_params ) ;
6666
6767 switch ( exec_params . exec_type ) {
@@ -90,7 +90,7 @@ export class Service extends ParentResourceService implements IService {
9090 if ( this . getService ( ) . memorycache . isResourceLive ( id , temporal_ttl ) ) {
9191 // we create a promise because we need return collection before
9292 // run success client function
93- var deferred = Core . Services . $q . defer ( ) ;
93+ var deferred = Core . injectedServices . $q . defer ( ) ;
9494 deferred . resolve ( fc_success ) ;
9595 deferred . promise . then ( fc_success => {
9696 this . runFc ( fc_success , 'memorycache' ) ;
@@ -100,7 +100,7 @@ export class Service extends ParentResourceService implements IService {
100100 }
101101
102102
103- Core . Services . JsonapiHttp
103+ Core . injectedServices . JsonapiHttp
104104 . get ( path . get ( ) )
105105 . then (
106106 success => {
@@ -134,9 +134,9 @@ export class Service extends ParentResourceService implements IService {
134134 params . remotefilter ? path . addParam ( paramsurl . toparams ( { filter : params . remotefilter } ) ) : null ;
135135 if ( params . page ) {
136136 params . page . number > 1 ? path . addParam (
137- Core . Services . rsJsonapiConfig . parameters . page . number + '=' + params . page . number ) : null ;
137+ Core . injectedServices . rsJsonapiConfig . parameters . page . number + '=' + params . page . number ) : null ;
138138 params . page . limit ? path . addParam (
139- Core . Services . rsJsonapiConfig . parameters . page . limit + '=' + params . page . limit ) : null ;
139+ Core . injectedServices . rsJsonapiConfig . parameters . page . limit + '=' + params . page . limit ) : null ;
140140 }
141141
142142 // make request
@@ -162,7 +162,7 @@ export class Service extends ParentResourceService implements IService {
162162 if ( this . getService ( ) . memorycache . isCollectionLive ( path . getForCache ( ) , temporal_ttl ) ) {
163163 // we create a promise because we need return collection before
164164 // run success client function
165- var deferred = Core . Services . $q . defer ( ) ;
165+ var deferred = Core . injectedServices . $q . defer ( ) ;
166166 deferred . resolve ( fc_success ) ;
167167 deferred . promise . then ( fc_success => {
168168 this . runFc ( fc_success , 'memorycache' ) ;
@@ -174,7 +174,7 @@ export class Service extends ParentResourceService implements IService {
174174 tempororay_collection [ '$isloading' ] = true ;
175175
176176 // STORAGE_CACHE
177- Core . Services . JsonapiHttpStorage
177+ Core . injectedServices . JsonapiHttpStorage
178178 . get ( path . getForCache ( ) , params . storage_ttl )
179179 . then (
180180 success => {
@@ -188,7 +188,7 @@ export class Service extends ParentResourceService implements IService {
188188
189189 this . runFc ( fc_success , { data : success } ) ;
190190
191- var deferred = Core . Services . $q . defer ( ) ;
191+ var deferred = Core . injectedServices . $q . defer ( ) ;
192192 deferred . resolve ( fc_success ) ;
193193 deferred . promise . then ( fc_success => {
194194 this . runFc ( fc_success , 'httpstorage' ) ;
@@ -205,7 +205,7 @@ export class Service extends ParentResourceService implements IService {
205205
206206 private getAllFromServer ( path , params , fc_success , fc_error , tempororay_collection : ICollection ) {
207207 // SERVER REQUEST
208- Core . Services . JsonapiHttp
208+ Core . injectedServices . JsonapiHttp
209209 . get ( path . get ( ) )
210210 . then (
211211 success => {
@@ -217,7 +217,7 @@ export class Service extends ParentResourceService implements IService {
217217 this . getService ( ) . memorycache . setCollection ( path . getForCache ( ) , tempororay_collection ) ;
218218
219219 if ( params . storage_ttl > 0 ) {
220- Core . Services . JsonapiHttpStorage . save ( path . getForCache ( ) , success . data ) ;
220+ Core . injectedServices . JsonapiHttpStorage . save ( path . getForCache ( ) , success . data ) ;
221221 }
222222
223223 // localfilter getted data
@@ -251,7 +251,7 @@ export class Service extends ParentResourceService implements IService {
251251 path . appendPath ( this . getPath ( ) ) ;
252252 path . appendPath ( id ) ;
253253
254- Core . Services . JsonapiHttp
254+ Core . injectedServices . JsonapiHttp
255255 . delete ( path . get ( ) )
256256 . then (
257257 success => {
@@ -268,7 +268,7 @@ export class Service extends ParentResourceService implements IService {
268268 @return This resource like a service
269269 **/
270270 public getService < T extends IService > ( ) : T {
271- return Converter . getService ( this . type ) ;
271+ return < T > Converter . getService ( this . type ) ;
272272 }
273273
274274 public clearMemoryCache ( ) : boolean {
0 commit comments