1 | var __extends = (this && this.__extends) || (function () {
|
2 | var extendStatics = Object.setPrototypeOf ||
|
3 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
4 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
5 | return function (d, b) {
|
6 | extendStatics(d, b);
|
7 | function __() { this.constructor = d; }
|
8 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
9 | };
|
10 | })();
|
11 | import { IonicDB } from '@ionic/db';
|
12 | var Database = (function (_super) {
|
13 | __extends(Database, _super);
|
14 | function Database(deps, settings) {
|
15 | var _this = _super.call(this, settings) || this;
|
16 | _this.deps = deps;
|
17 | _this.settings = settings;
|
18 | if (_this.settings.authType === 'authenticated') {
|
19 | _this.deps.emitter.on('auth:login', function (login) {
|
20 | if (login && login['token']) {
|
21 | _this.setToken(login['token']);
|
22 | }
|
23 | });
|
24 | _this.deps.emitter.on('auth:logout', function () {
|
25 | _this.removeToken();
|
26 | _this.disconnect();
|
27 | });
|
28 | }
|
29 | return _this;
|
30 | }
|
31 | return Database;
|
32 | }(IonicDB));
|
33 | export { Database };
|