@mjtickets981/common 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,5 +3,6 @@ export declare enum Subjects {
|
|
|
3
3
|
TicketUpdated = "ticket:updated",
|
|
4
4
|
OrderCreated = "order:created",
|
|
5
5
|
OrderCancelled = "order:cancelled",
|
|
6
|
-
ExpirationComplete = "expiration:complete"
|
|
6
|
+
ExpirationComplete = "expiration:complete",
|
|
7
|
+
PaymentCreated = "payment:created"
|
|
7
8
|
}
|
package/build/events/subjects.js
CHANGED
|
@@ -4,6 +4,16 @@
|
|
|
4
4
|
// Here we define all the subjects that our application will use.
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Subjects = void 0;
|
|
7
|
+
// What is the use of enum in TypeScript?
|
|
8
|
+
// An enum (short for "enumeration") is a special data type in TypeScript that allows you to define a set of named constants.
|
|
9
|
+
// Enums are useful for representing a fixed number of related values, such as days of the week, directions, or in our case, event subjects.
|
|
10
|
+
// They provide a way to give more meaningful names to these values, making the code easier to read and maintain.
|
|
11
|
+
// But why can't we write just export Subjects = { TicketCreated: "ticket:created", TicketUpdated: "ticket:updated", ... } instead of using enum?
|
|
12
|
+
// We could technically use a plain object to define our subjects, but using an enum provides several benefits:
|
|
13
|
+
// 1. Type Safety: Enums provide type safety, ensuring that only valid values can be assigned to variables of the enum type. With a plain object, you could accidentally assign an invalid string value.
|
|
14
|
+
// 2. Auto-completion: When using enums in an IDE, you get auto-completion for the enum values, which can help prevent typos and improve developer productivity.
|
|
15
|
+
// 3. Readability: Enums can make the code more readable by providing a clear and concise way to define a set of related constants. It also makes it clear that these values are meant to be used as a group of related options.
|
|
16
|
+
// 4. Reverse Mapping: Enums in TypeScript support reverse mapping, allowing you to get the name of an enum member from its value. This can be useful for debugging or logging purposes.
|
|
7
17
|
var Subjects;
|
|
8
18
|
(function (Subjects) {
|
|
9
19
|
Subjects["TicketCreated"] = "ticket:created";
|
|
@@ -11,5 +21,6 @@ var Subjects;
|
|
|
11
21
|
Subjects["OrderCreated"] = "order:created";
|
|
12
22
|
Subjects["OrderCancelled"] = "order:cancelled";
|
|
13
23
|
Subjects["ExpirationComplete"] = "expiration:complete";
|
|
24
|
+
Subjects["PaymentCreated"] = "payment:created";
|
|
14
25
|
})(Subjects || (exports.Subjects = Subjects = {}));
|
|
15
26
|
const printSubject = (subject) => { };
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -33,3 +33,4 @@ __exportStar(require("./events/types/order-status"), exports);
|
|
|
33
33
|
__exportStar(require("./events/order-created-event"), exports);
|
|
34
34
|
__exportStar(require("./events/order-cancelled-event"), exports);
|
|
35
35
|
__exportStar(require("./events/expiration-complete-event"), exports);
|
|
36
|
+
__exportStar(require("./events/payment-created-event"), exports);
|