src/services/model/modelItems/userMI.ts
A ModelItem that holds a AAAIUser.
Properties |
|
Methods |
|
constructor()
|
Defined in src/services/model/modelItems/userMI.ts:23
|
Public defaultValueSetter |
Type : function
|
Inherited from
ModelItem
|
Defined in
ModelItem:78
|
The |
Public identifier |
Type : string
|
Inherited from
ModelItem
|
Defined in
ModelItem:38
|
The |
Public initFunction |
Type : function
|
Inherited from
ModelItem
|
Defined in
ModelItem:83
|
The above code is defining a public property called |
Public initialised |
Default value : false
|
Inherited from
ModelItem
|
Defined in
ModelItem:44
|
The line |
Public isModelItem |
Default value : true
|
Inherited from
ModelItem
|
Defined in
ModelItem:33
|
The line |
Protected logging |
Default value : false
|
Inherited from
ModelItem
|
Defined in
ModelItem:106
|
The above code is defining a class in TypeScript with a protected property called "logging" that is set to false. |
Protected persistable |
Default value : false
|
Inherited from
ModelItem
|
Defined in
ModelItem:97
|
The above code is declaring a protected property named "persistable" and assigning it a value of false. |
Public persistableOnConfigurables |
Default value : false
|
Inherited from
ModelItem
|
Defined in
ModelItem:57
|
The line |
Protected persister |
Type : null | Persister
|
Inherited from
ModelItem
|
Defined in
ModelItem:93
|
The above code is declaring a protected property called "persister" with a type of either null or Persister. |
Public populatedOnInit |
Default value : false
|
Inherited from
ModelItem
|
Defined in
ModelItem:50
|
The line |
Public postPersistConverter |
Type : function
|
Inherited from
ModelItem
|
Defined in
ModelItem:71
|
The |
Public prePersistConverter |
Type : function
|
Inherited from
ModelItem
|
Defined in
ModelItem:64
|
The line |
Protected services |
Type : Record<string | >
|
Inherited from
ModelItem
|
Defined in
ModelItem:102
|
The above code is declaring a protected property called "services" of type "Record<string, unknown>". The "services" property is an object that can hold key-value pairs, where the keys are strings and the values can be of any type. |
Public valueObs |
Type : Observable<T>
|
Inherited from
ModelItem
|
Defined in
ModelItem:86
|
The above code is declaring a public variable called |
Protected valueSource |
Type : BehaviorSubject<T>
|
Inherited from
ModelItem
|
Defined in
ModelItem:89
|
The above code is declaring a protected variable called |
Public get |
get()
|
Inherited from
ModelItem
|
Defined in
ModelItem:303
|
Returns :
T
Current Value |
Public getContext |
getContext()
|
Inherited from
ModelItem
|
Defined in
ModelItem:343
|
The getContext function returns the context associated with a given identifier in the modelContext array.
Returns :
string
a string value. |
Public getModel |
getModel()
|
Inherited from
ModelItem
|
Defined in
ModelItem:319
|
Returns :
Model
The Model that this item is registered to. |
Protected getPersistedValue |
getPersistedValue()
|
Inherited from
ModelItem
|
Defined in
ModelItem:374
|
The function
Returns :
Promise<>
A Promise that resolves to an unknown value. |
Public getService | ||||||||
getService(service: string)
|
||||||||
Inherited from
ModelItem
|
||||||||
Defined in
ModelItem:330
|
||||||||
The function
Parameters :
|
Public init | ||||||||
init(services: Record
|
||||||||
Inherited from
ModelItem
|
||||||||
Defined in
ModelItem:157
|
||||||||
The
Parameters :
Returns :
void
|
Protected log | ||||||||||||
log(message?: string, ...optionalParams: Array<>)
|
||||||||||||
Inherited from
ModelItem
|
||||||||||||
Defined in
ModelItem:362
|
||||||||||||
The log function logs a message and optional parameters if logging is enabled. meaning it can be omitted when calling the function. its elements.
Parameters :
Returns :
void
|
Static make | ||||||||
make(defaultValue: T1)
|
||||||||
Inherited from
ModelItem
|
||||||||
Defined in
ModelItem:146
|
||||||||
Type parameters :
|
||||||||
The function "make" creates a new instance of the ModelItem class with a specified default value.
to the
Parameters :
Returns :
ModelItem<T1>
The method is returning an instance of the |
Static makeNullable | ||||||||||
makeNullable(defaultValue: null | T1)
|
||||||||||
Inherited from
ModelItem
|
||||||||||
Defined in
ModelItem:134
|
||||||||||
Type parameters :
|
||||||||||
The function "makeNullable" returns a new instance of "ModelItem" with a default value that can be
null or of type T1.
that allows you to specify a default value for the
Parameters :
Returns :
ModelItem<null | T1>
The method is returning a new instance of the |
Public populateValueOnInit |
populateValueOnInit()
|
Inherited from
ModelItem
|
Defined in
ModelItem:266
|
The function "populateValueOnInit" checks if a model item exists, sets its value from persistence, sets a default value if necessary, and marks it as populated on initialization. |
Public set | |||||||||||||||
set(value: T, force)
|
|||||||||||||||
Inherited from
ModelItem
|
|||||||||||||||
Defined in
ModelItem:283
|
|||||||||||||||
Sets the value
Parameters :
Returns :
void
|
Public setDefaultValueFunction | ||||||||
setDefaultValueFunction(defaultValueSetter: (modelItem: ModelItem
|
||||||||
Inherited from
ModelItem
|
||||||||
Defined in
ModelItem:207
|
||||||||
The function sets a default value for a model item using a provided callback function.
Parameters :
|
Protected setFromDefault |
setFromDefault()
|
Inherited from
ModelItem
|
Defined in
ModelItem:424
|
The function
Returns :
Promise<void>
The function |
Protected setFromPersistence |
setFromPersistence()
|
Inherited from
ModelItem
|
Defined in
ModelItem:394
|
The function
Returns :
Promise<void>
a Promise that resolves to void (undefined). |
Public setIdentifier | ||||||||
setIdentifier(id: string)
|
||||||||
Inherited from
ModelItem
|
||||||||
Defined in
ModelItem:233
|
||||||||
The function sets the identifier property of an object and returns the object itself.
Parameters :
|
Public setInitFunction | ||||||||
setInitFunction(initFunc: (modelItem: ModelItem
|
||||||||
Inherited from
ModelItem
|
||||||||
Defined in
ModelItem:221
|
||||||||
The
Parameters :
|
Private setInitialised | ||||||||
setInitialised(initialised)
|
||||||||
Inherited from
ModelItem
|
||||||||
Defined in
ModelItem:443
|
||||||||
The function sets the value of the "initialised" property to true by default, but can also accept a different value. an object or variable has been initialized or not.
Parameters :
Returns :
void
|
Public setPersistable | ||||||||
setPersistable(persistable)
|
||||||||
Inherited from
ModelItem
|
||||||||
Defined in
ModelItem:175
|
||||||||
The function sets the persistable property of an object and returns the object itself. an object should be persisted or not. If set to true, the object will be saved and stored for future use. If set to false, the object will not be persisted and will not be saved for future use.
Parameters :
|
Public setPersistableOnConfigurables | ||||||||
setPersistableOnConfigurables(value: boolean)
|
||||||||
Inherited from
ModelItem
|
||||||||
Defined in
ModelItem:245
|
||||||||
The function sets the value of the "persistableOnConfigurables" property and returns the instance of the class. on configurables.
Parameters :
|
Public setPersister | ||||||||
setPersister(persister: null | Persister)
|
||||||||
Inherited from
ModelItem
|
||||||||
Defined in
ModelItem:256
|
||||||||
The function sets the persister property of an object and returns the object itself. It is used to set the persister for the current object.
Parameters :
|
Public setPersistFunctions | ||||||||||||
setPersistFunctions(prePersistConverter, postPersistConverter)
|
||||||||||||
Inherited from
ModelItem
|
||||||||||||
Defined in
ModelItem:190
|
||||||||||||
The function sets pre-persist and post-persist converters for a model item.
ModelItem
Parameters :
|
Public trigger |
trigger()
|
Inherited from
ModelItem
|
Defined in
ModelItem:311
|
Results in the emitting of a notifications of change, but with the same value as before.
Returns :
void
|
import { ModelItem } from './modelItem';
import { AAAIUser } from 'api/aaai/aaaiUser.interface';
import { AaaiService } from 'api/aaai.service';
/**
* A {@link ModelItem} that holds a {@link AAAIUser}.
*/
export class UserMI extends ModelItem<null | AAAIUser> {
constructor(
) {
super(null);
this.setInitFunction((modelItem: ModelItem<AAAIUser>) => {
return new Promise((resolve) => {
const aaaiService = this.getService('AaaiService') as AaaiService;
// set current
this.set(aaaiService.getUser());
// on init, set up a watch
aaaiService.watchUser().subscribe((aaaiUser: null | AAAIUser) => {
if (aaaiUser !== this.get()) {
this.set(aaaiUser);
}
});
resolve();
});
});
}
}