SAP Spartacus OccCmsComponentAdapter findComponentsByIds method

Look at the six input parameters of this method:


TypeScript code:

const requestParams = {
      ...this.getContextParams(pageContext),
      ...this.getPaginationParams(currentPage, pageSize, sort),
    };

The corresponding JavaScript code:

  const requestParams = Object.assign(Object.assign({
    
    }, this.getContextParams(pageContext)), this.getPaginationParams(currentPage, pageSize, sort));


The Object.assign() method is used to copy the values ​​of all enumerable properties from one or more source objects to the target object. It will return the target object.

const target = {
    
     a: 1, b: 2 };
const source = {
    
     b: 4, c: 5 };

const returnedTarget = Object.assign(target, source);

console.log(target);
// expected output: Object { a: 1, b: 4, c: 5 }

console.log(returnedTarget);
// expected output: Object { a: 1, b: 4, c: 5 }

Return an Observable of HTTPResponse:



The get method is implemented by the request method:

The request method is just to construct
an Observable for a general HTTP request . Only after subscribing, will it go through the registered interceptor chain to fire the request.

Observable has a pipe method:

RxJS (Responsive Extended JavaScript Version) is a library that uses observables for reactive programming. It makes it easier to combine asynchronous code and callback-based code. The use of observable objects can be regarded as an observer mode. The simple process is that an observer (Observer) subscribes to an observable (Observable) through the subscribe() method. After subscribing, the observer (Obsever) can respond to the data or data sequence transmitted by the observable (the next function transmits data). There are three things involved: Observer, Observable, and subscribe.

To get more original articles by Jerry, please follow the public account "Wang Zixi":

Guess you like

Origin blog.csdn.net/i042416/article/details/108568889