Let's go back to our joint order service and build our two publishers for the events that we just created.
So inside the SRT directory I'll make a new folder of events.
Then inside there I'll make a new folder of publishers and side that I'm going to make two files one
I will call order created publisher and Order cancelled publisher.
Let's start off first with our order created publisher.
So remember what we need to import at the top the file we need to make sure we get our publisher base
class.
We also need to get our order created event so we'll get our publisher order created event.
And we also need that subjects them as well so we can specify the subject we should use when we publish
this event.
So subjects and I'll get all that from my company module
then inside of here we will export a new class called order created publisher that's gonna be extending
our publisher base class.
And remember this is a generic class where we stick in the event that we're going to eventually emit
so order created even were then told right away by typescript that we need to define that abstract property
so we could say that we're going to have a subject property we're going to annotate this properties
type as subjects dot order created and the value for it will be subjects dot order created and that's
very much it.
Now any time that you want to publish an event saying that an order has been created we would write
out something like new order created publisher.
Remember we will throw in our Nats client and then we would call publish and inside this object right
here we'd pass all of our different data properties.
So in our case that would be the idea of the order the user I.D. the status expires at and then some
information about the ticket itself.
That's pretty much it.
Let's not repeat the same process for the order canceled publisher as well.
So here's order it canceled publisher at the top.
We will once again do a import for subjects publisher and order canceled
from the common module will export a class of order canceled.
Publisher and that's going to be extending our publisher base class throw in our order a canceled event
and then once again we need to define the subject property on here.
So our subject will be of type subject subjects.
Order canceled and its value will be subject Scott.
Order canceled.
And that's it.
Well that's all we have to do to define a publisher inside of here.
So this is looking pretty good.
Let's take a pause right here.
We're going to go back over to our two root handlers in the next video and make use of these two publishers
to make sure that we publish some events at the appropriate time.