# Runtime Fields

Runtime Fields provide reactive and computed values used inside features.

They are used to derive state from configuration, cache computed results, and react to changes.

***

### Overview

Runtime Fields are used to:

* derive values from configuration
* cache computed state based on a key
* detect and react to value changes

They are commonly used together with `ConfigWatcher` and `OmsFeature`\
See [ConfigWatcher](/oms-wiki/developer-guide/core-architecture/feature-system.md#configwatcher)\
See [OmsFeature](/oms-wiki/developer-guide/core-architecture/feature-system.md#omsfeature)

***

### Core Types

#### CachedField

`CachedField` represents a key-based cached value.

The value is recomputed when the key changes and can optionally:

* validate computed values
* notify on updates
* be observed during runtime

{% @github-files/github-code-block url="<https://github.com/c0nnor263/OperateMyServer/blob/main/oms-api/src/main/kotlin/io/conboi/oms/api/foundation/CachedField.kt>" %}

***

### Usage

Runtime Fields are typically used inside features to:

* compute derived values from config
* track changes in configuration-dependent state
* avoid recomputing expensive logic

Fields are usually defined using a builder-style configuration.

***

### Notes

* Values are recomputed only when the key changes
* Fields can trigger update callbacks
* Observation is controlled via `watch()`
* Integrated with `ConfigWatcher` by providing an wrapper `configField`


---

# 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://conboi.gitbook.io/oms-wiki/developer-guide/runtime-infrastructure/runtime-fields.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.
