Dispatchable Trait Explained0:00
Let me point your attention to this line right here. We're dispatching a new ReconcileAccount job. However, take a look at this class, and you'll see it uses a trait called Dispatchable. Now if we dig down there, there are three methods available, but for now we're only focusing on this one here, a static method called dispatch, and you'll see all it does is it returns a new PendingDispatch, just like that helper function we had earlier. So you'll see right here, it returns a new PendingDispatch, exact same thing. Which means, if you want, and I think it actually looks a little bit better, rather than using the dispatch helper function, I could instead say ReconcileAccount::dispatch, and then you send through what is essentially your constructor args that way.
Using Class Dispatch0:42
the Dispatch Helper function, I could instead say ReconcileAccount, Dispatch, and then you send through what is essentially your constructor args that way. So this and this are functionally identical. But yeah, honestly, I prefer this approach, which means I can remove it entirely and still end up with the same end result. So if you like that, you're all set to go. But if you don't see yourself ever calling that Dispatch method, then you're free to remove the trait entirely, because you're never going to make use of those methods. But yeah, I'd recommend keep it around. It looks better.
