Services configuration
The current implementation of services uses static methods (like public static getCooperator(id: number...
) which makes it very easy for us to reference. The configuration comes from axiosBackend
only.
This comes with a major drawback in that there is no instance of the service, meaning we can't have two instances (with different settings) at the same time even if we wanted to.
If we convert the service method to instance methods (remove static
) and make them configurable:
class CooperatorService {
constructor(config) { ... }
...
}
We can then expose the configured instance in another file:
import ourconfig from './apiconfig';
const ConfiguredCooperatorService = new CooperatorService(ourconfig);
const ConfiguredAccessionService = new AccessionService(ourconfig);
export { ConfiguredCooperatorService as CooperatorService, ConfiguredAccessionService as AccessionService };
I'm looking for suggestions and comments to address this issue.