Constructor
Provides ValueHostsManager with numerous configuration settings. It is just a simple object that you may initialize like this:
{
services: createValidationServices(); <-- see and customize your create_services.ts file
valueHostConfigs: [
// see elsewhere for details on ValueHostConfigs as they are the heavy lifting in this system.
// Just know that you need one object for each value that you want to connect
// to the Validation Manager
],
savedInstanceState: null, // or the state object previously returned with OnInstanceStateChanged
savedValueHostInstanceStates: null, // or an array of the state objects previously returned with OnValueHostInstanceStateChanged
onInstanceStateChanged: (ValueHostsManager, state)=> { },
onValueHostInstanceStateChanged: (valueHost, state) => { },
onValueChanged: (valueHost, oldValue) => { },
onInputValueChanged: (valueHost, oldValue) => { }
onConfigChanged: (valueHost, valueHostConfig) => { }
}
Protected
loggerProvides an API for logging, sending entries to the loggerService.
Protected
configAccess to the ValidationServices.
Protected
valueValueHosts for all ValueHostConfigs. Always replace a ValueHost when the associated Config or InstanceState are changed.
Protected
valueValueHostConfigs supplied by the caller (business logic). Always replace a ValueHost when its Config changes.
Protected
instanceValueHostInstanceStates and more. A copy of this is expected to be retained (redux/localstorage/etc) by the caller to support recreating the ValueHostsManager in a stateless situation.
Alternative to getValueHost that returns strongly typed valuehosts in a shortened syntax. Always throws exceptions if the value host requested is unknown or not the expected type.
Use this when caching the configuration for a later creation of ValueHostsManager.
Called when the configuration of ValueHosts has been changed, usually through the ValueHostsManagerConfigModifier.apply, or these members of ValueHostsManager: addValueHost, addOrUpdateValueHost, addOrMergeValueHost, discardValueHost. The supplied object is a clone so modifications will not impact the ValueHostsManager.
Called when the ValueHostsManager's state has changed. React example: React component useState feature retains this value and needs to know when to call its setState function with the stateToRetain
Called when any ValueHost had its ValueHostInstanceState changed. React example: React component useState feature retains this value and needs to know when to call the setValueHostInstanceState() with the stateToRetain. You can setup the same callback on individual ValueHosts. Here, it aggregates all ValueHost notifications.
Called when the ValueHost's Value property has changed. If setup, you can prevent it from being fired with the options parameter of setValue() to avoid round trips where you already know the details. You can setup the same callback on individual ValueHosts. Here, it aggregates all ValueHost notifications.
Called when the InputValueHost's InputValue property has changed. If setup, you can prevent it from being fired with the options parameter of setValue() to avoid round trips where you already know the details. You can setup the same callback on individual InputValueHosts. Here, it aggregates all InputValueHost notifications.
Provides a way to enumerate through existing ValueHosts.
Optional
filter: ((valueHost) => boolean)A generator that yields a tuple of [valueHostName, IValueHost]
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.
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.
a clone of this instance will be retained. Can use builder.static(), builder.calc() or any ValueConfigHost. (builder is the Builder API)
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.
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.
a clone of this instance will be retained. Can use builder.static(), builder.calc() or any ValueConfigHost. (builder is the Builder API)
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.
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.
a clone of this instance will be retained. Can use builder.static(), builder.calc() or any ValueConfigHost. (builder is the Builder API)
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.
Protected
applyCreates 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.
a clone of this instance will be retained
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.
Protected
invokeEasier 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.
Retrieves the ValueHost associated with valueHostName
Matches to the IValueHost.name property Returns the instance or null if not found.
Retrieves the StaticValueHost of the identified by valueHostName
Matches to the IStaticValueHost.name property Returns the instance or null if not found or found a non-input valuehost.
Retrieves the CalcValueHost of the identified by valueHostName
Matches to the ICalcValueHost.name property Returns the instance or null if not found or found a non-input valuehost.
Upon changing the value of a ValueHost, other ValueHosts need to know. They may have Conditions that take the changed ValueHost into account and will want to revalidate or set up a state to force revalidation. This goes through those ValueHosts and notifies them.
Report that a ValueHost had its instance state changed. Invokes onValueHostInstanceStateChanged if setup.
Protected
validatableProtected
resolveStatic
safeGenerated using TypeDoc v0.25.12
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.