Skip to content

DatastoreConfig

Mihael Safaric edited this page Sep 27, 2024 · 7 revisions

A decorator used for configuring a datastore service. It takes one argument, DatastoreOptions

Options

  • network: NetworkConfig

  • halDocumentClass

    • sets a class on a datastore level which will be used instead of default HalDocument class (if not provided on a model level)
  • paginationClass

    • mandatory, an instance of that class will be created while creating HalDocument instance
  • cacheStrategy: CacheStrategy

    • optional
    • defines which caching stragery should be used
    • possible values
    • default: CacheStrategy.NONE
    • for more information see Caching Strategies
    • when CacheStrategy.CUSTOM, storage property must be provided
  • storage : HalStorage

Example

import { HttpClient } from '@angular/common/http';
import { DatastoreService, DatastoreConfig } from 'ngx-hal';

@DatastoreConfig({
  network: {
    baseUrl: 'mydomain.com'
  },
  paginationClass: MyPagination
})
export class HalDatastoreService extends DatastoreService<MyPagination> {
  constructor(public httpClient: HttpClient) {
    super(httpClient);
  }
}