Object-oriented programming

Through its use of the latest ECMAScript, Lightning Web Component controllers are able to leverage Object-Oriented Programming (OOP) principles using syntax that is recognizable by those more familiar with Apex. As you have seen through the code samples in this chapter, the use of inheritance is already used extensively when creating a component controller:

import { LightningElement, api } from 'lwc';

export default class Race extends LightningElement {
// ...
}

This enables you to define your own base class for common functionality across all your components. This could be an alternative to explicitly asking each component to import a utility library, as shown earlier in this chapter. Much like with Apex, you can also override base class methods and leverage the super keyword to call base class methods as needed. Interfaces, however, are not yet implemented. You can read more about ECMAScript classes here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes#Defining_classes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.122.4