PumpContainer: SingletonKosModelRegistrationBean<PumpContainerModel, PumpContainerOptions> = ...

PumpContainer

The registration bean includes convenience methods for creating and working with PumpContainerModel instances.

type

The type property is a string that identifies the model type. The type is used to identify the model type in the model registry and to narrow down the model type in type predicates. It's most frequently used when declaring dependencies on models.

Example


@kosDependency({modelType: PumpContainer.type})
private holderContainerModel: PumpContainerModel;

factory

The factory function that can be used to create new PumpContainerModel instances.

As this is a singleton model, the factory function accepts the model options as its argument.

If a model with the same model type 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.

Example

const model = PumpContainer.factory({ });

predicate

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

Example


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

if (PumpContainer.predicate(model)) {
// if the function evaluates to true, the model is narrowed down to PumpContainerModel
// and the compiler will know that the model has the PumpContainerModel interface
model.updateAvailability(false);
}

registration

The registration property is an object that can be used to simplify registration of the model with the model registry. The registration object can be spread into the model registration and provides all of the required information to register the model implementation class against the model type.

Example

In an application registration file you can declare the model registration as follows:

registration.ts

import { PumpContainer } from "@kosdev-code/kos-dispense-sdk";
...
import { IKosRegistry } from "@kosdev-code/kos-ui-sdk";
export const kosModels: IKosRegistry["models"] = {
...PumpContainer.registration,
};

registration.singleton

The PumpContainer model is a singleton. This means that each time the factory function is called , the same instance will be returned. If the model does not yet exist, it will be created passing in the provided options to initialize it.