---
title: "StateFactory"
sidebar_label: "StateFactory"
description: "Kotlin binding reference: StateFactory."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.runtime](../index.md)/[StateFactory](index.md)

# StateFactory

[common]\
fun interface [StateFactory](index.md)

A model's per-session state factory: any object, or null for no state. It runs with the session's stream as the thread's placement. A state that is `AutoCloseable` is closed when the engine releases the session; one that implements [BatchableState](../BatchableState/index.md) is read by the batcher.

## Functions

| Name | Summary |
|---|---|
| [run](run.md) | [common]<br>abstract fun [run](run.md)(): [Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)? |