LEC vs. EC
What is the difference between the LEC and the EC? The LEC is a local Event Controller.rn
Video Transcript
00:00Okay, so now that when you finish talking about the event controller in its format in the EC,
00:06let's talk about the LEC.
00:08And when would you use the LEC? The LEC stands for local event controller.
00:12And there are quite a lot of instances where you would want to work with the LEC instead of the event controller directly.
00:19Now all the same mythology of working with the add, remove, and log work the exact same way.
00:25The only difference is that we're going to create a local version for the local event controller to run it locally.
00:33Now, why would you use that? For example, if you're building a component and you don't want external users to have access to it,
00:40or if you're working in object-oriented programming and you really want to be strict and work in the style and format that is most standard
00:48in working in object-oriented programming where you hide anything that's inside of the object not to be accessible from out of it.
00:56In that scenario, or even if you want to be more flexible, you want to make sure that it's easier for you to track certain events.
01:03You want to put the section in one bucket and another section in another bucket.
01:07It gives you more freedom to make decisions of creating different buckets instead of working with one large bucket.
01:14The way to work with it is very easy. This video is not going to be very long.
01:19Instead of working with the EC, we're going to change the name to LEC.
01:23The first thing we want to do here after that is we want to create a private variable called LEC.
01:32It's going to be a type LEC.
01:34The first thing before we even start interacting with it, we want to create a new LEC.
01:40Done. Now we have our local event controller instantiated and we can work with our local event controller.
01:45You can work with as many local event controllers as you want.
01:48The more local event controllers you have, the better strategy you need to figure out on monitoring them.
01:56In every case, every scenario, you need to figure out do you want to work with a local event controller,
02:01do you want to work with a global one, and with how many of them.
02:04To make sure that the more you added them, obviously the more management you have to add into your code.
02:10Now that we have our LEC created, we can actually just run through all our ECs.
02:16AC. and just replace it with LEC.
02:19And just replace all is going to find 16 items.
02:22And that's all I had to do to actually make the LEC work.
02:26And if I run the application, now it's going to do the exact same thing.
02:31Hopefully.
02:33And we have your little snafu.
02:36Let's see what's going on here.
02:41Let's try to run this one more time.
02:43Oh, I forgot to update the number of the constructor.
02:54That would do it.
02:56And here we go.
02:58So everything is working the same way as it is, as it was.
03:01You can click on the items.
03:03As soon as you click on the green button, everything gets deactivated.
03:06The only two items that have not been removed are these two items because we removed only items that were associated with our UID.
03:14And when we do our output, we're going to see that we have those two unclustered items that are still there.
03:20And they are listed out right here.
03:24So that's really all you really need to know how to work with the LEC.
03:30The LEC is all what we talked about about the adding, removing, and logging events have the same type of rules with the LEC as well.
03:38Let's just make a log of everything.
03:41Run it.
03:43So we're going to remove again.
03:45Remove everything.
03:46Make a log.
03:48And now you can see again that there's only two items that are unclustered in our event at all, in our LEC controller.
03:55And now it's not a global manager, it's a local manager.
