In this concept Narik has These services:

  • RemoteDataProviderService

  • QueryService

  • UrlCreatorService

  • UrlCreator


You can use this service to communicate with remote servers. This service uses provided metadata and UrlCreatorService to find the appropriate way to communicate.

Data Info Metadata


Currently, this service has some methods to do CRUD actions;

* abstract get(info: DataInfo): Observable<ServerResponse<T>>;
* abstract getList(info: DataInfo): Observable<ServerResponse<T[]>>;
* abstract post(info: DataInfo, data: any): Observable<ServerResponse<T>>;
* abstract delete(info: DataInfo, data: any): Observable<ServerResponse<any>>;
  • UrlCreatorService You may use different technologies in the remote server. but it's not important for Narik at all. You can define the way that URLs should be created and parameters must be sent to the remote server. In metadata you can specify "defaultRemoteDataProvider", for example "odata". Then you create a class that implements UrlCreator, for example, "ODataUrlCreator" and provide it as UrlCreator. Narik already did it for "odata" and "api".

    UrlCreatorService manages all UrlCreators in the application.

    example :

      import { formatString } from "@narik/common";
      import { UrlCreator, PagingParameters } from "@narik/infrastructure";
      import { Injectable } from "@angular/core";
      export class ApiUrlCreator extends UrlCreator {
          key = "api";
          applyParameters(url: string, parameters: any): string {
              if (!parameters) {
              return url;
              return formatString(
              url.indexOf("?") >= 0 ? "" : "?",
                  .map(x => {
                  return formatString("{0}={1}", x, parameters[x]);
              url: string,
              pagingParameter: PagingParameters
          ): string {
              throw new Error("Method not implemented.");
          provide: UrlCreator,
          useClass: ApiUrlCreator,
          multi: true

Last updated