> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dairy.foundation/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

<Note>
  Core is a union of Dairy's Core runtime extensions and a number of utilities
  that depend upon it, or the android platform.
</Note>

Dairy's Core is the backbone of many add-on libraries. It enables many new
patterns when writing FTC code, and Core is useful both for end users, who want
to apply these patterns and utilities to improve their FTC code, and for authors
of libraries, for whom Core provides a toolbox and base against which its easy
to write powerful FTC libraries, that automatically play nice with the rest of
the Dairy platform, and impose minimal further impact on teams.

<Warning>
  Once Core is installed, you **must** add the `FeatureRegistrar` runtime hooks to
  your `LinearOpMode` code. This will happen automatically for `OpMode`. For this
  reason, Dairy recommends using `OpMode`. Failure to do so may cause undefined
  behaviour. See here for examples: [Java](https://github.com/Dairy-Foundation/Dairy/blob/master/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/examples/JavaLinearOpMode.java)
  [Kotlin](https://github.com/Dairy-Foundation/Dairy/blob/master/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/examples/KotlinLinearOpMode.kt).
</Warning>

<Warning>
  Once Core is installed, you **must not** use `sleep` or similar blocking code
  (like while loops) to structure `LinearOpMode` autonomous code. Instead, write
  'asynchronous polled' friendly code. This style of code take the form of update
  functions that get run (polled) every loop, and does not block the loop
  (asynchronous). This must not be done in `OpMode` either, but this is much
  harder to do in `OpMode`. `Feature`s rely on the hooks running, and you lose
  many of the benefits of Dairy, or may cause undefined / unexpected behaviour
</Warning>

# Features:

* `Feature`s are components that have hooks into the OpMode runtime.
* The `Dependency` system allows `Feature`s to declare the conditions that need
  to be met for them to be attached to an OpMode, whether this is an annotation
  or another `Feature`.
* `Controller`s have support for systems like PID controllers, or
  MotionProfiles, that update in the background of your OpMode.
* `OpModeLazyCell` allows you to separate out your hardware access into several
  functions.
* OpMode templating via `OpModeLazyCell` and the enhanced Dairy runtime, an
  improved alternative to a `RobotHardware` class.
* `EnhancedDoubleSupplier`s and `EnhancedBooleanSupplier`s that rely on the
  Dairy runtime to automatically provide additional utilities.
* A unit test runtime currently suitable for testing libraries that use Dairy,
  hopefully later suitable for testing user code.

# Installation:

<Note>
  Core bundles a copy of Util and Sinister along with itself, however, those
  libraries may have newer updates than the current version of Core, so check if
  you need to install them separately.
</Note>

<Warning>
  Currently Util is ahead of Core, you must install it separately.
</Warning>

1. Repository

<Info>
  This only needs to be done once, if you already have this, no need to add it
  again.
</Info>

Add

```gradle theme={null}
repositories {
	maven {
		url "https://repo.dairy.foundation/releases"
	}
}
```

To `TeamCode`'s `build.gradle`, above `dependencies`.

2. Implementation

Add the newest version of Core found
[here](https://repo.dairy.foundation/#/releases/dev/frozenmilk/dairy/Core) to
the `dependencies` block:

```gradle theme={null}
dependencies {
	// ...
	implementation "dev.frozenmilk.dairy:Core:<MAJ.MIN.ENG>"
	// ...
}
```

The repo will give you the line to add.

3. Sync

Run a gradle sync.
