Core
Instructions

Instructions

Add Instruction

This is the base factory for all other instructions. It is responsible for adding some function to a work-queue and returning the placeholder to becomes a special property on a model.

Signature

namespace Model {
  namespace Instruct {
    type Getter<T> = (source: Model) => T;
    type Setter<T> = (value: T, current: T) => boolean | void | (() => T);
 
    type Descriptor<T = any> = {
      get?: Getter<T> | boolean;
      set?: Setter<T> | false;
      enumerable?: boolean;
      value?: T;
    }
  }
 
  type Instruct<T = any, M extends Model = any> =
    (this: M, key: Field<M> & string, thisArg: M, state: State<M>) =>
      Instruct.Descriptor<T> | Instruct.Getter<T> | void;
}
function add<T = any>(instruction: Instruct): T