linagora / esn-frontend-common-libs

Common ground for OpenPaaS frontend (https://open-paas.org)
Other
4 stars 12 forks source link

Have a common AngularJS factory for esnApiClient #126

Closed itswillta closed 4 years ago

itswillta commented 4 years ago

We need to have a common place to avoid initializing esnApiClient mutiple times in our code. Something like this will be cool:

const Client = require('esn-api-client/src/Client').default;

angular.module('esn.api-client', [])
  .factory('esnApiClient', function($q, $window) {
    return new Client({ baseURL: $window.location.origin, customPromise: $q });
  });

And then in our AngularJS code we just use it as a normal AngularJS dependency, without having to constructing Client multiple times.

itswillta commented 4 years ago

We need to change the code here also: https://github.com/OpenPaaS-Suite/esn-dav-import-client/blob/efdb044809dc60cd8986c94121dadee842920d55/src/ESNDavImportClient.js