devdocs icon indicating copy to clipboard operation
devdocs copied to clipboard

Add info about implementing or changing private content using customer-data.js

Open kweij opened this issue 5 years ago • 0 comments

General issue

This page does not give me information about how to implement, change or use private content using customer-data.js.

Description:

It starts of with "This example displays a customer’s name on a cacheable page", but that's not happening anywhere on the pages. Currenty this pages contains alot of links to files as examples, but doesn't describe the working of the files or the relevant code.

The section "Create a block and template" throws some terms about without any structure or explanation, like "Use a UIComponent", "Do not use $_isScopePrivate", "Initialize the component as follows" (without content examplary for $block->getJsLayout();). Perhaps this is very logical for someone who already knows how it all works, but I have no experience with writing custom private data handling so I'm here to learn it.

The section "Configure a UI component" is another blob of unstructured data, like "All properties are available in the template." and links to files without any context.

The only relevant information I got from these two sections was customerData.get('section-name'); that is used in one of the files linked in there. But, without context that one line didn't do the trick for me.

Regarding: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/cache/page-caching/private-content.html

Possible solutions:

It would be very useful if this pages explains the concept of private data first and then explains how to get custom data from backend to frontend with the least possible clutter. If I knew how it worked I would now give a proposal about how this works, but I can't. I know these element in the chain but I can't link them together in a working way:

  • section source (provider + DI)
  • how to fetch the data using customerData.js
  • how to invalidate data (sections.xml and perhaps other methods in JS)

Thanks in advance for any more explanation about how to implement and use private content using customer-data.js.

kweij avatar Apr 06 '20 06:04 kweij