Skip to content

Commit 69b9e1e

Browse files
committed
Refactored useable interfaces into Api module
Added some tests for correct decorator declarations regarding microsoft/TypeScript#4888
1 parent 17ca0ad commit 69b9e1e

File tree

10 files changed

+1941
-1751
lines changed

10 files changed

+1941
-1751
lines changed

js/main/Db3.d.ts

+581-522
Large diffs are not rendered by default.

js/main/Db3.js

+45-44
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
/**
2-
* TSDB version : VERSION_TAG
2+
* TSDB version : 20150924_222714_master_1.0.0_17ca0ad
33
*/
44
var __extends = (this && this.__extends) || function (d, b) {
55
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
66
function __() { this.constructor = d; }
7-
__.prototype = b.prototype;
8-
d.prototype = new __();
7+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
98
};
109
var Firebase = require('firebase');
1110
var PromiseModule = require('es6-promise');
1211
var Promise = PromiseModule.Promise;
13-
var Version = 'VERSION_TAG';
12+
var Version = '20150924_222714_master_1.0.0_17ca0ad';
1413
/**
1514
* The main Db module.
1615
*/
@@ -48,6 +47,39 @@ var Db;
4847
return defaultDb;
4948
}
5049
Db.getDefaultDb = getDefaultDb;
50+
var Api;
51+
(function (Api) {
52+
/**
53+
* Various kind of events that can be triggered when using {@link EventDetails}.
54+
*/
55+
(function (EventType) {
56+
/**
57+
* Unknown event type.
58+
*/
59+
EventType[EventType["UNDEFINED"] = 0] = "UNDEFINED";
60+
/**
61+
* The value has been updated, used on entities when there was a change and on collections when an elements
62+
* is changed or has been reordered.
63+
*/
64+
EventType[EventType["UPDATE"] = 1] = "UPDATE";
65+
/**
66+
* The value has been removed, used on root entities when they are deleted, embedded and references when
67+
* they are nulled, references also when the referenced entity has been deleted, and on collections when
68+
* an element has been removed from the collection.
69+
*/
70+
EventType[EventType["REMOVED"] = 2] = "REMOVED";
71+
/**
72+
* The value has been added, used on collections when a new element has been added.
73+
*/
74+
EventType[EventType["ADDED"] = 3] = "ADDED";
75+
/**
76+
* Special event used on collection to notify that the collection has finished loading, and following
77+
* events will be updates to the previous state and not initial population of the collection.
78+
*/
79+
EventType[EventType["LIST_END"] = 4] = "LIST_END";
80+
})(Api.EventType || (Api.EventType = {}));
81+
var EventType = Api.EventType;
82+
})(Api = Db.Api || (Db.Api = {}));
5183
/**
5284
* Internal module, most of the stuff inside this module are either internal use only or exposed by other methods,
5385
* they should never be used directly.
@@ -214,36 +246,6 @@ var Db;
214246
return BindingImpl;
215247
})();
216248
Internal.BindingImpl = BindingImpl;
217-
/**
218-
* Various kind of events that can be triggered when using {@link EventDetails}.
219-
*/
220-
(function (EventType) {
221-
/**
222-
* Unknown event type.
223-
*/
224-
EventType[EventType["UNDEFINED"] = 0] = "UNDEFINED";
225-
/**
226-
* The value has been updated, used on entities when there was a change and on collections when an elements
227-
* is changed or has been reordered.
228-
*/
229-
EventType[EventType["UPDATE"] = 1] = "UPDATE";
230-
/**
231-
* The value has been removed, used on root entities when they are deleted, embedded and references when
232-
* they are nulled, references also when the referenced entity has been deleted, and on collections when
233-
* an element has been removed from the collection.
234-
*/
235-
EventType[EventType["REMOVED"] = 2] = "REMOVED";
236-
/**
237-
* The value has been added, used on collections when a new element has been added.
238-
*/
239-
EventType[EventType["ADDED"] = 3] = "ADDED";
240-
/**
241-
* Special event used on collection to notify that the collection has finished loading, and following
242-
* events will be updates to the previous state and not initial population of the collection.
243-
*/
244-
EventType[EventType["LIST_END"] = 4] = "LIST_END";
245-
})(Internal.EventType || (Internal.EventType = {}));
246-
var EventType = Internal.EventType;
247249
/**
248250
* Class describing an event from the Db. It is used in every listener callback.
249251
*/
@@ -252,7 +254,7 @@ var Db;
252254
/**
253255
* The type of the event, see {@link EventType}.
254256
*/
255-
this.type = EventType.UNDEFINED;
257+
this.type = Api.EventType.UNDEFINED;
256258
/**
257259
* The payload of the event.
258260
*
@@ -880,9 +882,9 @@ var Db;
880882
SingleDbHandlerEvent.prototype.handleDbEvent = function (ds, prevName) {
881883
this.parseValue(ds);
882884
var evd = new EventDetails();
883-
evd.type = EventType.UPDATE;
885+
evd.type = Api.EventType.UPDATE;
884886
if (this.entity == null) {
885-
evd.type = EventType.REMOVED;
887+
evd.type = Api.EventType.REMOVED;
886888
}
887889
evd.payload = this.entity;
888890
evd.originalEvent = 'value';
@@ -1495,7 +1497,7 @@ var Db;
14951497
return new Promise(function (resolve, error) {
14961498
var allProms = [];
14971499
_this.updated(ctx, function (det) {
1498-
if (det.type == EventType.LIST_END) {
1500+
if (det.type == Api.EventType.LIST_END) {
14991501
det.offMe();
15001502
if (allProms.length) {
15011503
Promise.all(allProms).then(function () {
@@ -1506,7 +1508,7 @@ var Db;
15061508
resolve(_this.realField);
15071509
}
15081510
}
1509-
if (det.type != EventType.ADDED)
1511+
if (det.type != Api.EventType.ADDED)
15101512
return;
15111513
if (_this.isReference && deref) {
15121514
var evt = _this.findCreateChildFor(det.originalKey);
@@ -1561,7 +1563,7 @@ var Db;
15611563
this.loaded = true;
15621564
}
15631565
handler.ispopulating = false;
1564-
det.type = EventType.LIST_END;
1566+
det.type = Api.EventType.LIST_END;
15651567
handler.handle(det);
15661568
return;
15671569
}
@@ -1570,13 +1572,13 @@ var Db;
15701572
subev.parseValue(ds);
15711573
val = subev.entity;
15721574
if (event == 'child_removed') {
1573-
det.type = EventType.REMOVED;
1575+
det.type = Api.EventType.REMOVED;
15741576
}
15751577
else if (event == 'child_added') {
1576-
det.type = EventType.ADDED;
1578+
det.type = Api.EventType.ADDED;
15771579
}
15781580
else {
1579-
det.type = EventType.UPDATE;
1581+
det.type = Api.EventType.UPDATE;
15801582
}
15811583
det.payload = val;
15821584
if (handler.istracking) {
@@ -3109,4 +3111,3 @@ var defaultDb = null;
31093111
*/
31103112
var entEvent = new Db.Utils.WeakWrap();
31113113
module.exports = Db;
3112-
//# sourceMappingURL=Db3.js.map

js/main/Db3.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)