Interface KosModelRegistrationBean<T, O>

KosModelRegistrationBean *

interface KosModelRegistrationBean<T, O> {
    predicate: ((model) => model is T);
    factory: IdentifiableModelFactory<T, O>;
}

Type Parameters

  • T extends IKosDataModel
  • O extends object = Record<string, any>

Hierarchy

  • BaseKosModelRegistrationBean<T, O>
    • KosModelRegistrationBean

Properties

Properties

predicate: ((model) => model is T)

Typescript type predicate function that will identify and narrow down a model to a .

Type declaration

    • (model): model is T
    • Parameters

      • model: IKosDataModel

      Returns model is T

Example


const model: IKosDataModel = ...; // some model

if (Beverage.predicate(model)) {
// if the function evaluates to true, the model is narrowed down to AvailabilityModel
// and the compiler will know that the model has the AvailabilityModel interface
model.updateAvailability(false);
}
factory: IdentifiableModelFactory<T, O>

The factory method creates a factory function that can be used to create new model instances.

The factory function is a curried function that takes the model id as the first argument and the options as the second argument.

If a model with the specified id already exists, the factory function will return the existing model. The options will be ignored in this case and the existing model will be returned in its current state.