> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# Method name: onReadyAsync()

# Method package: w

# Method menu location: w --> Dataset --> onReadyAsync

# Method Link: https://dev.wix.com/docs/velo/velo-only-apis/$w/dataset/on-ready-async.md

# Method Description:

The `onReadyAsync()` function returns a Promise that resolves when a dataset is ready.

Similar to the [`onReady()`](https://dev.wix.com/docs/velo/api-reference/$w/dataset/on-ready.md) function, the `onReadyAsync()` function allows you
 to optionally perform actions once a dataset is ready. A dataset is ready after it has loaded its data
 from the collection and updated all connected page elements with their corresponding values.
 `onReadyAsync()` differs from `onReady()` in that `onReadyAsync()` is promise-based,
 whereas `onReady()` is based on callback functions.



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## Get the dataset's current item after the dataset is ready

```javascript
$w.onReady(async () => {
  await $w('#myDataset').onReadyAsync();
  let currentItem = $w('#myDataset').getCurrentItem();
  console.log(currentItem);
} );

/*  
 *  {
 *    "_id":                "fcec780a-3e37-4b64-8a66-37c552c53f99",
 *    "_owner":             "f6c0f9c3-a62d-7e9f-g58d-943829af244d9",
 *    "_createdDate":       "2017-05-01T17:19:03.823Z",
 *    "_updatedDate":       "2017-05-01T17:19:10.477Z",
 *    "title":              "Dr. ",
 *    "name":               "John",
 *    "age":                "50"
 *  }
 */
```

## Get and add the total number of items from multiple datasets after they are ready

```javascript
$w.onReady(async () => {
  const promise1 = $w('#myDataset1').onReadyAsync();
  const promise2 = $w('#myDataset2').onReadyAsync();

  await Promise.all([promise1, promise2]);
  const combinedTotal = $w('#myDataset1').getTotalCount() + $w('#myDataset2').getTotalCount(); 
  console.log(`Combined total items in both datasets: ${combinedTotal}`); //8
} );
```

## Get the total number of items after the dataset is ready

```javascript
$w.onReady(async () => {
  //onReady
  await $w("#myDataset").onReady( () => {
    let onReadyTotalCount = $w("#myDataset").getTotalCount(); //4
  } );

  //onReadyAsync
  await $w("#myDataset").onReadyAsync();
  let onReadyAsyncTotalCount = $w("#myDataset").getTotalCount(); //4
} );

```

---