NgrxData, How to add custom function other than the default ones in the DefaultDataService<T>

133 Views Asked by At

I'm trying to build an app with NgRXData (https://ngrx.io/guide/data), and I want to add new functions in the DataService of one of the models, I understood that you only can override an existing functions that exists in the DefaultDataService<T> (https://ngrx.io/api/data/DefaultDataService) but you can't add extra new functions to it, even if I just did this:

export class MyCustomDataService extends DefaultDataService<MyModel> {
  constructor(http: HttpClient, httpUrlGenerator: HttpUrlGenerator, logger: Logger) {
    super('MyModel', http, httpUrlGenerator);
    logger.log('Created custom MyModel EntityDataService');
  }

  getAll(): Observable<MyModel[]> {
    return super.getAll().pipe(map(lst => lst.map(model => this.mapMyModel(model))));
  }
  
  newFunction(): Observable<MyModel> {
     // just get the data and map it.
  }

Is newFunction gonna be linked to the store to be updated?

0

There are 0 best solutions below