Make provider Name part of API

This commit is contained in:
Anthony Laibe 2018-08-24 09:05:56 +01:00
parent fa0e8e3770
commit 6b93af0b75
3 changed files with 18 additions and 15 deletions

View File

@ -6,16 +6,17 @@ Messages.registerProvider = function (providerName, obj) {
this.Providers[providerName] = obj; this.Providers[providerName] = obj;
}; };
Messages.setProvider = function (provider, options) { Messages.setProvider = function (providerName, options) {
let providerObj = this.Providers[provider]; let provider = this.Providers[providerName];
if (!providerObj) { if (!provider) {
throw new Error('Unknown messages provider'); throw new Error('Unknown messages provider');
} }
this.currentMessages = providerObj; this.currentMessagesName = providerName;
this.currentMessages = provider;
return providerObj.setProvider(options); return provider.setProvider(options);
}; };
Messages.isAvailable = function () { Messages.isAvailable = function () {

View File

@ -7,16 +7,17 @@ Names.registerProvider = function (providerName, obj) {
Names.Providers[providerName] = obj; Names.Providers[providerName] = obj;
}; };
Names.setProvider = function (provider, options) { Names.setProvider = function (providerName, options) {
let providerObj = this.Providers[provider]; let provider = this.Providers[providerName];
if (!providerObj) { if (!provider) {
throw new Error('Unknown name system provider'); throw new Error('Unknown name system provider');
} }
this.currentNameSystems = providerObj; this.currentNameSystemsName = providerName;
this.currentNameSystems = provider;
return providerObj.setProvider(options); return provider.setProvider(options);
}; };
// resolve resolves a name into an identifier of some kind // resolve resolves a name into an identifier of some kind

View File

@ -51,16 +51,17 @@ Storage.registerProvider = function (providerName, obj) {
this.Providers[providerName] = obj; this.Providers[providerName] = obj;
}; };
Storage.setProvider = function (provider, options) { Storage.setProvider = function (providerName, options) {
let providerObj = this.Providers[provider]; let provider = this.Providers[providerName];
if (!providerObj) { if (!provider) {
throw new Error('Unknown storage provider'); throw new Error('Unknown storage provider');
} }
this.currentStorage = providerObj; this.currentStorageName = providerName;
this.currentStorage = provider;
return providerObj.setProvider(options); return provider.setProvider(options);
}; };
Storage.isAvailable = function () { Storage.isAvailable = function () {