Oxform
API

Subscriptions

Observe a selected form, field, or array value through a Solid accessor.

Subscriptions

createSubscribe(api, selector)

Returns Accessor<Selected>. The selector receives the form, field, or array's store state, and its return value determines the accessor's type. Read the accessor in JSX or a tracking scope.

Selections compare with Object.is. Unrelated updates that leave the selected value identical do not rerun consumers. A freshly allocated object is a changed selection even when its contents match.

import { ,  } from '@oxform/solid';
import {  } from 'zod';

function () {
  const  = ({ : .({ : .() }), : { : '' } });
  const  = (,  => ..);
  return <>{()}</>;
}

An API accessor such as createSubscribe(() => currentForm(), selector) switches subscriptions when its API changes. The owner unsubscribes on disposal. Server rendering reads the initial selection without subscribing.

Subscribe

PropContract
apiForm, field, or array API to observe. Dynamic JSX props can switch it.
selectorSelect a value from current store state.
childrenRender function receiving an accessor, called as selected().

The component adds no DOM wrapper. Its child receives the accessor, rather than the selected value itself:

import { ,  } from '@oxform/solid';
import {  } from 'zod';

function () {
  const  = ({ : .({ : .() }), : { : '' } });
  return (
    < ={} ={ => ..}>
      { => (
        < ='submit' ={()}>
          Submit
        </>
      )}
    </>
  );
}

Use createFormEffect for callbacks on selected changes and createFormStatus for aggregate status getters.

Types

Prop

Type