Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
900 B
3
Indexable
Never
  getProducts(){
    this.storeService.fetchRestaurantsAndProducts()
    .subscribe(
      (response: any) => {
        // Call Web-worker to not block UI when converting data
        if (typeof Worker !== 'undefined') {
          // Create a new
          const worker = new Worker(new URL('./home.worker', import.meta.url));
          worker.onmessage = ({ data }) => {
            this.products = data;
          };
          // Load products response and process it with worker
          worker.postMessage(response[1]);
        } else {
          // Web Workers are not supported in this environment.
          // You should add a fallback so that your program still executes correctly.
          console.log('This browser does not support Web Workers');
          //this.products = Object.values(response[1]).flatMap((child: any) => Object.values(child.Productos));
        }
      }
    );
  }