 Hello. Hi. So, fine. This is a little experiment I was working on. I finished it all yesterday. So, this is basically implementing the actor pattern in JavaScript. Now, JS as such might not be the ideal platform for something like this, because it's all single threaded. But, yeah, you can probably invoke it eventually for racing programming with stuff like, say, web workers and Ajax calls and on Node.js this will work like a charm. So, I just want to do it first. What is an actor? Now, actor best way to say it is, if you have a bit of code that can run on its own, you can represent it using an actor, okay? So, actors are like human beings. Actors have some, you know, state in them like, you know, our memory. And actors have some behavior, you know, that decides how they act. Yeah, they act. And actors talk to each other using messages, just like we human beings do. This is a very organic, it's a very intuitive way of dealing with situations. This comes in very handy with, you know, async code, especially in terms of, you know, say, separation of concern number one, number two, you limit the mutable state. For example, the state variable of the actor, that is the only one which can be changed. Further, we enforce that you only change that variable whenever someone tells the actor something. I'm like, hey, do this. Only at that time will that side effect be introduced. And last thing is async code, you won't go through orbit, callback, hell, and all. So, one quick implementation I made, I used the sync code flux by Facebook. It suited my needs with a little modification. I'll just tell you what changed here to comment out some code from that. But eventually, to give an example of an actor, I'll just show you. So, what example I've used is there's an auction, okay? So, in an auction, we've got, say, the seller, you've got a bunch of bidders, and I've also created someone called a logger who keeps writing down whatever is happening around here. So, how it works is, in an auction, the buyer, what does he need to know about? It's a blind auction, say. So, he just needs to know about whether... I'll get back to that. So, he needs to know whether this thing is fine, what do you call that? Whether he is currently winning the auction or not? Not coming. Yeah, cool. So, yeah, the bidder only needs to know whether my bid, the bid that I'm making, is successful or not. The auction needs to keep track of stuff, something like, what is the minimum bid? What is the current maximum bid? And stuff like, if there's a bid that's greater than the current bid, then what do I do? So, in an actor perspective, it looks like this. You have the auction. Someone tells the auction, hey, start. Now, once the auction starts, you probably, yeah, the auction has started. Now, if someone makes an inquiry, you can tell them that, hey, the current maximum bid is so and so. And then, you know, the bidder can make a bid. You can respond to the bidder saying that, hey, your bid is not good enough. Or if the bid is good enough, then you tell him, hey, your bid has succeeded. And the previous person who had the biggest bid, you tell him that, hey, someone just overbid you. So, I'll just show you some code. This might be better. So, this is the simplest actor out here. It's the logger. He just writes down whatever happens. The data is blank because the logger does not need to have any state. Yeah, the action, it looks like this. So, you get a payload. That is a message that the actor is telling. And data is the existing data, which is blank for now. And all you do is you log. I received a log from this guy. And the value is so and so. Little more complicated would be the bidders. Now bidder, all that the bidder would want to know is, hey, am I winning the auction or not? And so, yeah, you look at the messages. So, basically, the payload is coming in. That is a message. And it can have a few states. So, if I get a state saying it's finished, it means that, hey, I won the auction. Because I'm only going to tell it's finished to the person who has the maximum bid. If I get a message, say, check reply. It means that I had made an inquiry. I got a response from the auction saying, okay, I mean, this is the current state. And again, stuff like failure is whenever I bid less than what I needed to, success is if I bid correctly more than what I needed to, overtake me and say, someone just bid more than you. So, it's really neat and all. If you can imagine writing this in a single monolithic block and it'll be extremely ugly. Similarly, some data for the auction. So, auction will keep track of, say, if the auction is active or not, and he needs to respond to inquiries and bids and so on. So, here you've got something like, say, start, stop. Is it finished? Is there a check? And putting it all together is really simple. So, if you can look at this, this is all. This last part is all. Here, you register, you guys. And then you just say, hey, start the auction. Okay. So, bidder one makes a check. He gets the status. Bidder one makes a bid with a value of five. Bidder two overbids him. So, bidder one would probably get a message after this. Bidder two checks. Bidder one checks. And then somehow I tell him that, hey, stop the auction. So, if you want to see the logs from here. Now, may I, it's time. Hey, I'll just show the final log and I'll show. Yeah. How do you inspect element in the console? Just go to right click in. Right click inspect element. Yeah. So, you can see the console out here. Can I maximize this? Fine. So, he started the status. Bidder one checked. Bidder one got a reply saying so and so. His bid was successful. Bidder two made a bid. His bid was more than that. So, it was successful. And then, yeah, you check again and then you reply and the whole flow. So, yeah, basically this will work out really well if you're writing event-driven code. If you're working on node, if you're going to be working with web workers, callbacks, something like the scrollback thing yesterday, perhaps. And it'll scale very easily. So, yeah, if you need to, yes, discuss about this later, I should be there.