Skip to content

Latest commit

 

History

History
124 lines (76 loc) · 2.13 KB

File metadata and controls

124 lines (76 loc) · 2.13 KB
id TanStackStoreAtom
title TanStackStoreAtom

Class: TanStackStoreAtom<TValue>

Defined in: tan-stack-store-atom.ts:29

Subscribes a Lit host to a writable atom and exposes its current value along with a stable setter.

Use this when an element needs to both read and update the same writable atom. The host will only re-render when the atom's value actually changes (according to the configured compare function).

Example

class CounterEl extends LitElement {
  `#count` = new TanStackStoreAtom(this, () => countAtom)

  render() {
    return html`
      <button @click=${() => this.#count.set((prev) => prev + 1)}>
        ${this.#count.value}
      </button>
    `
  }
}

Type Parameters

TValue

TValue

Constructors

Constructor

new TanStackStoreAtom<TValue>(
   host, 
   getAtom, 
options?): TanStackStoreAtom<TValue>;

Defined in: tan-stack-store-atom.ts:32

Parameters

host

ReactiveControllerHost

getAtom

() => Atom<TValue> | undefined

options?

UseSelectorOptions<TValue>

Returns

TanStackStoreAtom<TValue>

Accessors

value

Get Signature

get value(): TValue | undefined;

Defined in: tan-stack-store-atom.ts:43

Returns

TValue | undefined

Methods

set()

Call Signature

set(value): void;

Defined in: tan-stack-store-atom.ts:47

Parameters
value

TValue

Returns

void

Call Signature

set(updater): void;

Defined in: tan-stack-store-atom.ts:48

Parameters
updater

(prev) => TValue

Returns

void