Magento 2 Knockout JS in a Nutshell

We have defined a module with a simple module.xml and a registration.php file,

to call upon the regular flow of M2 merged XML layouts, to define a Block class that feeds data into a PHTML template,

which is then outputting a JSON configuration array that was inserted into the Block class using an XML argument-array,

and which is then used to initialize a custom AMD-style JS component through the Magento_Ui/js/core/app component,

which connects our require JS component to our KnockoutJS component.

Then, our JS component injects the customer-data component to collect a bit of information about the customer, which is fetched through a kind of local-storage-cached-AJAX-call to the backend,

which is configured through a DI type that injects an array of section sources into a backend class,

that fetches data from various sources, including our own, to then send back a bundled response, if possible, to the JS component, with the major feature being JavaScript AJAX lazy loading.

Namespace

/Module

/Block

Block.php

/etc

module.xml

/view

/frontend

/layouts

somelayout_file.xml

/templates

template.phtml

registration.php