Enumeration ChildrenIdCardGetterInterfaceSignal

The ChildrenIdCardGetterInterfaceSignal lists all the signals that may be sent by the ChildrenIdCardGetterInterface.

These signals are emitted by the ChildrenIdCardGetterInterface when some data is available.

/** 
* Sample to illustrate the use of an ChildrenIdCardGetterInterface with the parsing of
* PartInstanceInfoInterface to display some information about a part instance.
*/
import {
VisibilityContextInterface, ChildrenIdCardGetterInterface, ChildrenIdCardGetterInterfaceSignal,
InfiniteEvent, ChildrenPartInstanceInfoInterface, PartInstanceInfoStatusFlag, DataSessionInterface
} from 'generated/documentation/appinfiniteapi';

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;
// created previously
let lVisibilityContext : VisibilityContextInterface;
// the `part instance id` to get
let lPartInstanceId : number;
// what to do when we have retrieved id card information ?
let onChildrenIdCardReady : (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) => void;

// create an ChildrenIdCardGetter
const lChildrenIdCardGetterInterface : ChildrenIdCardGetterInterface = lDataSession.createChildrenIdCardGetter();
// what to do when result is ready ?
lChildrenIdCardGetterInterface.addEventListener(ChildrenIdCardGetterInterfaceSignal.ChildrenIdCardReady, onChildrenIdCardReady);

// onChildrenIdCardReady will be called when data is available
onChildrenIdCardReady = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
if (lChildrenIdCardGetterInterface.getLastError().length !== 0) {
// do nothing in case of error
// perhaps some GUI code ?
}
const lPartInstanceInfos : Array<ChildrenPartInstanceInfoInterface> | undefined = lChildrenIdCardGetterInterface.getPartInstanceInfos();
if (!lPartInstanceInfos || lPartInstanceInfos.length !== 1)
{
// no data (isCancelled ?)
return;
}
// we required only one `part instance`, as such, only one result should be retrieved
// iterate over the instantiation chain, but take the first chain since one `part instance` retrieved
const lCurrentChildren : ChildrenPartInstanceInfoInterface = lPartInstanceInfos[0];

// number of items
const lNbChildren : number = lCurrentChildren.getChildren().length;
if (lNbChildren <= 0)
{
console.log('this part instance is a leaf');
return;
}
// take the last child
const lChildInstanceOffset : number = lNbChildren - 1;
// we get the `part` metadata of the last child of the `part instance`
const lPartMetadata : Object = lCurrentChildren.getChildrenIdCard().partmd[lChildInstanceOffset];
// some fancy output
console.log(JSON.stringify(lPartMetadata));

// get the flags in order to get information about the `part instance`
const lFlags : number = lCurrentChildren.getChildrenStatusFlags()[lChildInstanceOffset];
if ((lFlags & PartInstanceInfoStatusFlag.PI_Displayable) !== 0)
{
console.log('the last child of the part instance is displayable')
}
}

// trigger the retrieval
lChildrenIdCardGetterInterface.retrieveChildrenIdCard(lPartInstanceId, lVisibilityContext);

Please refer to [ChildrenIdCardGetterInterface](../interfaces/ChildrenIdCardGetterInterface.html) for more information about children idcard requests.
Events

See

ChildrenIdCardGetterInterface

Enumeration Members

ChildrenIdCardCancelled: "cancelled"

Signal sent by the ChildrenIdCardGetterInterface when the ChildrenIdCardGetterInterface is requested to be cancelled.

Such an event is fired if the ChildrenIdCardGetterInterface was running and cancel is called. The ChildrenIdCardReady signal will be triggered shortly after.

No attachment for events of this type.

ChildrenIdCardReady: "ready"

Signal sent by the ChildrenIdCardGetterInterface when the ChildrenIdCardGetterInterface is ready, i.e. getPartInstanceInfos can be called.

Warning, the ChildrenIdCardReady signal is sent when cancel is called and the ChildrenIdCardGetterInterface is updating. In such a case, not data will be available in the ChildrenIdCardGetterInterface.

The attachment is a string telling the request id of the call to retrieveChildrenIdCard (getLastRequestId).