-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Amplify.ts
56 lines (47 loc) · 1.64 KB
/
Amplify.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { ConsoleLogger as LoggerClass } from './Logger';
const logger = new LoggerClass('Amplify');
export default class Amplify {
private static _components = [];
private static _config = {};
// for backward compatibility to avoid breaking change
// if someone is using like Amplify.Auth
static Auth = null;
static Analytics = null;
static API = null;
static Storage = null;
static I18n = null;
static Cache = null;
static PubSub = null;
static Interactions = null;
static Pushnotification = null;
static XR = null;
static Logger = LoggerClass;
static ServiceWorker = null;
static register(comp) {
logger.debug('component registered in amplify', comp);
this._components.push(comp);
if (typeof comp.getModuleName === 'function') {
Amplify[comp.getModuleName()] = comp;
} else {
logger.debug('no getModuleName method for component', comp);
}
}
static configure(config) {
if (!config) return this._config;
this._config = Object.assign(this._config, config);
logger.debug('amplify config', this._config);
this._components.map(comp => {
comp.configure(this._config);
});
return this._config;
}
static addPluggable(pluggable) {
if (pluggable && pluggable['getCategory'] && typeof pluggable['getCategory'] === 'function') {
this._components.map(comp => {
if (comp['addPluggable'] && typeof comp['addPluggable'] === 'function') {
comp.addPluggable(pluggable);
}
});
}
}
}