Provides a container for ValueHosts that can be used when working with a model or form. It works together with IValueHostsServices. Since IValueHostsServices doesn't deal with validation services, ValueHostsManager doesn't support ValueHosts inheriting from ValidatableValueHostBase, including Input and Property, as those are built for validation. IValueHostsServices does handle conditions, so it can be shared with Conditions that need services.

Ultimately in Jivs, it supports the ValidationManager, but can work stand-alone. Conditions are passed the ValueHostsManager meaning they can be used independently of validation.

Type Parameters

Hierarchy (view full)

Implements

Constructors

Accessors

Methods

  • Use to change anything in ValueHostsManagerInstanceState without impacting the immutability of the current instance. Your callback will be passed a cloned instance. Change any desired properties and return that instance. It will become the new immutable value of the instanceState property.

    Parameters

    • updater: ((stateToUpdate) => TState)

      Your function to change and return a state instance.

    Returns boolean

    true when the state did change. false when it did not.

  • Adds a ValueHostConfig for a ValueHost not previously added. Does not trigger any notifications. Exception when the same ValueHostConfig.name already exists.

    Parameters

    • config: ValueHostConfig

      a clone of this instance will be retained. Can use builder.static(), builder.calc() or any ValueConfigHost. (builder is the Builder API)

    • initialState: null | ValueHostInstanceState

      When not null, this state object is used instead of an initial state. It overrides any state supplied by the ValueHostsManager constructor. It will be run through ValueHostFactory.cleanupInstanceState() first. When null, the state supplied in the ValueHostsManager constructor will be used if available. When neither state was supplied, a default state is created.

    Returns IValueHost

  • Replaces a ValueHostConfig for an already added ValueHost. It does not merge. If merging is required, use the ValueHostConfigMergeService first. Does not trigger any notifications. If the name isn't found, it will be added. Any previous ValueHost and its config will be disposed. Be sure to discard any reference to the ValueHost instance that you have.

    Parameters

    • config: ValueHostConfig

      a clone of this instance will be retained. Can use builder.static(), builder.calc() or any ValueConfigHost. (builder is the Builder API)

    • initialState: null | ValueHostInstanceState

      When not null, this state object is used instead of an initial state. It overrides any state supplied by the ValueHostsManager constructor. It will be run through ValueHostFactory.cleanupInstanceState() first.

    Returns IValueHost

  • Replaces a ValueHostConfig for an already added ValueHost. It merges the new config with the existing one using the ValueHostConfigMergeService. The goal is to protect important business logic settings while allowing the UI to inject new property values where appropriate. Does not trigger any notifications. If the name isn't found, it will be added. Any previous ValueHost and its config will be disposed. Be sure to discard any reference to the ValueHost instance that you have.

    Parameters

    • config: ValueHostConfig

      a clone of this instance will be retained. Can use builder.static(), builder.calc() or any ValueConfigHost. (builder is the Builder API)

    • initialState: null | ValueHostInstanceState

      When not null, this state object is used instead of an initial state. It overrides any state supplied by the ValueHostsManager constructor. It will be run through ValueHostFactory.cleanupInstanceState() first.

    Returns IValueHost

  • Creates the IValueHost based on the config and ensures ValueHostsManager has correct and corresponding instances of ValueHost, ValueHostConfig and ValueHostInstanceState. Any previous ValueHost and its config will be disposed.

    Parameters

    • config: ValueHostConfig

      a clone of this instance will be retained

    • initialState: null | ValueHostInstanceState

      When not null, this ValueHost state object is used instead of an initial state. It overrides any state supplied by the ValueHostsManager constructor. It will be run through ValueHostFactory.cleanupInstanceState() first.

    Returns IValueHost

  • Easier way to add or modify a ValueHostConfig than using addValueHost(), addOrUpdateValueHost(), or addOrMergeValueHost(). It returns an object whose methods allow adding ValueHosts and their validators. Upon calling its apply() method, your changes will be applied through the addOrMergeValueHost() function.

    let vm = new ValueHostManager(config);
    // later when you need to modify vm:
    let modifier = vm.startModifying();
    // supply changes to the ValueHostConfigs
    modifier.input('Field3').regExp(null, { enabled: false }); // let's disable the existing validator
    // merge those changes into the ValueHostManager
    modifier.apply(); // consider modifier disposed at this point

    Any ValueHost that gets updated will have its original instance disposed. Be sure to discard any reference to the ValueHost instance that you have.

    Returns ValueHostsManagerConfigModifier<ValueHostsManagerConfig>

Generated using TypeDoc v0.25.12