# @getforma/core/tc39

The optional class-based State and Computed compatibility API.

These are Forma's optional compatibility classes, not native browser APIs or a claim that a TC39 proposal has shipped. Import this subpath explicitly.

Published declaration: [@getforma/core@3.0.0](https://unpkg.com/@getforma/core@3.0.0/dist/tc39-compat.d.ts).

## Values and functions

### Computed

Class export

```ts
declare class Computed<T> {
    constructor(fn: () => T);
    get(): T;
}
```

TC39-compatible computed value.
Equivalent to `Signal.Computed` in the TC39 proposal.

```ts
const count = new State(0);
const doubled = new Computed(() => count.get() * 2);
console.log(doubled.get()); // 0
count.set(5);
console.log(doubled.get()); // 10
```

### State

Class export

```ts
declare class State<T> {
    constructor(initialValue: T, options?: SignalOptions<T>);
    get(): T;
    set(value: T): void;
}
```

TC39-compatible reactive state container.
Equivalent to `Signal.State` in the TC39 proposal.

```ts
const count = new State(0);
console.log(count.get()); // 0
count.set(1);
```

Related declarations: [`SignalOptions`](/docs/3.0/api-core/#symbol-SignalOptions)

## Other entry points

[@getforma/core](/docs/3.0/api-core/) · [@getforma/core/runtime](/docs/3.0/api-runtime/) · [@getforma/core/runtime-hardened](/docs/3.0/api-runtime-hardened/) · [@getforma/core/runtime-csp](/docs/3.0/api-runtime-csp/) · [@getforma/core/http](/docs/3.0/api-http/) · [@getforma/core/storage](/docs/3.0/api-storage/) · [JSX namespace](/docs/3.0/api-jsx/)