@@ -6,7 +6,7 @@ import { Resource } from './resource';
66import { ParentResourceService } from './parent-resource-service' ;
77import { PathBuilder } from './services/path-builder' ;
88import { UrlParamsBuilder } from './services/url-params-builder' ;
9- import { Converter } from './services/resource- converter' ;
9+ import { Converter } from './services/converter' ;
1010import { LocalFilter } from './services/localfilter' ;
1111import { MemoryCache } from './services/memorycache' ;
1212
@@ -76,13 +76,11 @@ export class Service extends ParentResourceService implements IService {
7676 public _get ( id : string , params : IParamsResource , fc_success , fc_error ) : IResource {
7777 // http request
7878 let path = new PathBuilder ( ) ;
79- path . appendPath ( this . getPrePath ( ) ) ;
80- path . appendPath ( this . getPath ( ) ) ;
79+ path . applyParams ( this , params ) ;
8180 path . appendPath ( id ) ;
82- params . include ? path . setInclude ( params . include ) : null ;
8381
8482 // cache
85- let resource = Converter . newResource ( this . type , id , true ) ;
83+ let resource = this . getService ( ) . memorycache . getOrCreateResource ( this . type , id , true ) ;
8684 resource . is_loading = true ;
8785 // exit if ttl is not expired
8886 let temporal_ttl = params . ttl ? params . ttl : 0 ;
@@ -126,10 +124,7 @@ export class Service extends ParentResourceService implements IService {
126124 // http request
127125 let path = new PathBuilder ( ) ;
128126 let paramsurl = new UrlParamsBuilder ( ) ;
129- path . appendPath ( this . getPrePath ( ) ) ;
130- params . beforepath ? path . appendPath ( params . beforepath ) : null ;
131- path . appendPath ( this . getPath ( ) ) ;
132- params . include ? path . setInclude ( params . include ) : null ;
127+ path . applyParams ( this , params ) ;
133128 params . remotefilter ? path . addParam ( paramsurl . toparams ( { filter : params . remotefilter } ) ) : null ;
134129 if ( params . page ) {
135130 params . page . number > 1 ? path . addParam (
@@ -140,7 +135,7 @@ export class Service extends ParentResourceService implements IService {
140135
141136 // make request
142137 // if we remove this, dont work the same .all on same time (ej: <component /><component /><component />)
143- let tempororay_collection = this . getService ( ) . memorycache . getCollection ( path . getForCache ( ) , true ) ;
138+ let tempororay_collection = this . getService ( ) . memorycache . getOrCreateCollection ( path . getForCache ( ) , true ) ;
144139
145140 // MEMORY_CACHE
146141 let temporal_ttl = params . ttl ? params . ttl : this . schema . ttl ;
@@ -246,8 +241,7 @@ export class Service extends ParentResourceService implements IService {
246241 private _delete ( id : string , params , fc_success , fc_error ) : void {
247242 // http request
248243 let path = new PathBuilder ( ) ;
249- path . appendPath ( this . getPrePath ( ) ) ;
250- path . appendPath ( this . getPath ( ) ) ;
244+ path . applyParams ( this , params ) ;
251245 path . appendPath ( id ) ;
252246
253247 Core . injectedServices . JsonapiHttp
0 commit comments