> For the complete documentation index, see [llms.txt](https://krypt0nn.gitbook.io/empathize/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://krypt0nn.gitbook.io/empathize/api/meta-classes/configs.md).

# Configs

### Configs.file

Path to file where the config will be stored. By default - `./config.json`

### Configs.serialize

A function that will encode an object to a string. By default - `JSON.stringify`

### Configs.unserialize

A function that will decode an object from a string. By default - `JSON.parse`

### Configs.autoFlush = true

Empathize has two models of working with your config files. The first and default is when all the changes save directly to the config file, so on your disk, and the second is when all the changes are saved in your application memory before you'd call `Configs.flush()` method to save them to your config file

![Configs.set() saves data to the config file, and Configs.get() fetches this data directly from your disk](/files/dYDyMFftqkW4gBjItnz2)

This model will prevent your application from various bugs caused by several windows usage, but it also will mean that every `Configs.set()` call it will write some data to your disk, which is not really good, and `Configs.get()` will fetch configs from the disk which also means additional delay

![Configs.set() and Configs.get() works with your application's memory, and Configs.flush() writes changes to the disk](/files/N0RvZQxkA75XZKo5A5EV)

With `autoFlush = false` all the config changes will be stored in your application's memory. To save these changes to the disk you'll need to call `Configs.flush()` method. This model will highly increase overall performance, but also requires you to develop your application carefully, so different windows will flush their config changes properly

### Configs.get(name)

```typescript
import { Configs } from '@empathize/framework';

// Some config
Configs.get('example_config').then((value) => {
    console.log(`Value: ${value}`);
});

// All the configs
Configs.get().then((config) => {
    for (const key of Object.keys(config))
        console.log(`${key}: ${config[key]}`);
});
```

### Configs.set(name, value)

```typescript
import { Configs } from '@empathize/framework';

Configs.set('example.config', {
    example_field: 'example value'
});
```

### Configs.remove(name)

```typescript
import { Configs } from '@empathize/framework';

Configs.remove('example.config');
```

### Configs.defaults(configs)

```typescript
import { Configs } from '@empathize/framework';

// Set default config values
Configs.defaults({
    example: {
        value_1: 1,
        value_2: 2
    },
    value_3: 3
});
```

### Configs.flush()

Saves config from the application's memory to the disk

```typescript
import { Configs } from '@empathize/framework';

Configs.flush();
```

### Configs.load()

Loads config from the disk to the application's memory. Uses to load configs changes from another window, because all the windows have separate memories, and changes in one window will be unavailable in another

```typescript
import { Configs } from '@empathize/framework';

Configs.load();
```
