@formkit/observer

Introduction

FormKit Observer is a utility to wrap a FormKitNode in a dependency tracking observer proxy.

Functions

createObserver()

Creates the observer.

Signature

Parameters

  • node — The FormKitNode to observe.
  • dependencies — The dependent nodes and the events that are required to watch for changes.

Returns

Returns a FormKitObservedNode.

diffDeps()

Determines which nodes should be added as dependencies and which should be removed.

Signature

Parameters

  • previous — The previous watcher dependencies.
  • current — The new/current watcher dependencies.

Returns

A tuple of maps: toAdd and toRemove.

isKilled()

Checks if the given node is revoked.

Signature

Parameters

  • node — Any observed node to check.

Returns

A boolean indicating if the node is revoked.

removeListeners()

Remove all the receipts from the observed node and subtree.

Signature

Parameters

  • receipts — The FormKit observer receipts to remove.

TypeScript

FormKitObservedNode

An API-compatible FormKitNode that is able to determine the full dependency tree of nodes and their values.

FormKitWatchable

A callback to watch for nodes.