# Waiting For Initilalization

When using persistent enmaps, it's very important to understand that *it takes time to load the data from the database*. Attempting to use the enmap before it's fully loaded can lead to errors, so we need to make sure it's ready before using it.

## Using *defer*

To make sure that all your data is loaded before you start working, Enmap provides a handy property called `defer` , which is a promise that is resolved once the provider is ready and all the data has been loaded into memory. There are a few ways to use `defer` , since it's a promise.&#x20;

```javascript
const Enmap = require('enmap');
const myEnmap = new Enmap({ name: 'test' });

// Using the standard .then() promise method: 

myEnmap.defer.then( () => {
  console.log(myEnmap.size + " keys loaded");
  myEnmap.set("blah", "foo"); // works
  myEnmap.get("thing"); // also works
});

// Using async/await as an immediate function: 
(async function() {
  await myEnmap.defer;
  console.log(myEnmap.size + " keys loaded");
  // Ready to use!
}());

// In an EventEmitter context:
myEmitter.on("eventName", async (arg) => {
  await myEnmap.defer;
  console.log(myEnmap.size + " keys loaded");
});
```

> For more information on async/await and promises, see [My JavaScript Guide](https://evie.gitbook.io/js/promises).

## Checking for Ready

Enmap also provides a `isReady`  option that tells you if the database is loaded. You can use that however you want, though the preferred method is using `defer`.

```javascript
if(myEnmap.isReady) { 
  // database is ready
} else {
  // database isn't loaded yet
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://evie.gitbook.io/enmap/francais/usage/init.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
