By the way, I left pending the part of cold where an event is made that after countdown ends, if you
go to the cold in time a service, you can see that before we were emitting this event in the process
called the method with this uncompleted permit.
The problem is that even the meters belong to components, not services.
Even the meters is a mechanism the TANGELA gives you in order to push information outside of the component.
So because of process, count on to the service.
I have to for a different approach to tell my component in a synchronous way that my candle has finished
and it to use the observer pattern.
This is exactly with the ATP service of Bangalor.
That's when you use the method ganef example.
This that htp that get of you.
Well, this is returning and and absorbable is an object that implements the pattern behavior with a
flow of information along time.
So unobservable allows you to subscribe with a function that will be called each time you observe or
receive any value you can use subscribe in order to do this.
And inside you define another function that receives this data.
And inside this function, you do whatever you want every time you receive the event.
OK, so you'll do the same with the time of service.
I of all this, I open to my complaints and now imagine this timer as returning unobservable and I call
this absorbable, coming to and saying so I use it here.
There's a timer comes on and dolar.
This is a frequent convention to say that this property here is an absorbable in this case.
This is not going to return any value it just to announce the count them half-finished.
So I subscribe here because this is returning unobservable here inside.
I'm not passing this data because it said this absurd well is not going to return any value, any insight
now that you are already in the company and you can use the event the meter as before.
So I can cancel as I had before countdown and and then use this that complete that I because this uncomplicate
now it exists on my component.
It's an multimeter.
There's a missing detail in that side to prevent memorialise.
You should cancel the subscription when the component is destroyed.
But in order to do so, you need the reference to the subscription.
So what I'm going to do is just come here, declare the property.
I count countdown and subscription.
It's going to be a type subscription.
And I said, of course, to import this subscription from Eric SJS and now I need to get the reference
to this subscription.
I use this that countdown and subscription equals my current subscription.
So now I get the reference and then in my energy undestroyed, I can call this that Canyonlands subscription
that unsubscribe.
This is the easiest part, how to use the absorbable if the service gives you unobservable.
The only thing you need is to use it subscribing like this and unsubscribing like that.
OK, but how to create the absorbable here is where things can get a little bit and I'm going to show
you how to do it here.
In time of service.
You need to declare a property of type subject here on the private countdown and source.
Equals new subject of type Boit, because I said this absorbable is not going to return anything, it
will only omit events.
I have to import the subject from here.
OK, what is the subject?
This is not a class about reactive programming.
That's a huge topic.
And if you're interested about it, I really recommend you to read the docs on HTP reactive ICS that
I o slash are SJS Reactive extorts about several libraries on this topic and experience is the JavaScript
library.
Anyway, what you need to do is that a subject is a acceptable object that can handle several subscriptions
and that can also limit events.
However, you don't want the company to subscribe directly to the subject because you don't want to
create events from outside.
You want to create events, but you don't want your company to use this time or create events.
So the company will only have access to the observable part of your subject.
Because of that, you need to create a public property because you want access from outside downtown.
And those are the observable we were using on the other side equals this that com source that as observable
because this object, this continent source is an acceptable and more things.
It is an asset bubble because you can subscribe to it, but it also allows you to omit events.
However, discount on dollar we are creating is only an observable great.
You have a private property that great events and the public one that provides the results of the other.
And you have subscribed this last one from the company.
Now we have to make this time around event.
Remember, we do this in Brussels scandal here.
It is commendable because Uncomplicate doesn't work here.
But what I can do is there's that condom and sors.
So subject that next.
And with next a meeting, any event inside next I can send the values.
In my case, this is an empty event, so I want to put any value inside.
I can remove this comment from here because I am doing so on the component side and that's all.
If we put a short canon to go faster, three seconds, for example, and we go to the browser to see
the results, you can see now how this message of the candombe finish is shown on the console when the
timer ends.
And that has been omitted not from time or service, but from time, a component this calendar in here.
So to sum up, what I have achieved is to push an event outside of the component by generated from the
service.
In fact, I can move to my app components creating a method like Countdown and.
And here inside is gunsel Countdown has finished, use it from my XHTML.
So here at this.
I'm complete equals look.
Down and I can copy this and paste them a different calendars.
I moved to them a component to remove also this console lock.
And then what I'm hearing now is that when I count on hand, led by this time, our service ends.
It emits an event.
This event is also emitted through my company.
And then it finally arrives through this binding to the Uncomplicate event on the template, it arrives
to the root component.
So when I click play on here, I wait.
And then this cannon has finished has been emitted not by the timer component, but by the root component.
I've been able to pass an event from inside tooltip.