ice-utils v1.1.2
Ice Utils

A set of utilities that makes using ZeroC ICE with JS easier.
Installation
npm install --save ice-utilsAPI
toPromise(icePromise: Ice.Promise): Promise
Turn Ice promise to normal one. Useful with async/await because awaiting
Ice promises leads to infinite loops.
Example
async function fn() {
const icePromise = myPrx.someOperation();
const result = await toPromise(icePromise);
return result;
} numberToLong(num: number): Ice.Long
Convert number to Ice.Long. Ice only provides method to convert Ice.Long
to number, but reverse conversion is necessary if you need to supply operation
parameter of type long, or implement a servant method that returns long.
See JavaScript Mapping for Long Integers.
operation(name?: string): MethodDecorator
Decorator factory for convenient operation implementation on servants.
Automatically adds ["amd"] metadata because sync operations make little sense
in JS world.
Parameters
- name: Operation name. Defaults to decorated method name.
Example
class MyServant extends MySlices.MyServant {
@operation()
myOperation() {
return doSomeStuff()
.then(doSomeOtherStuff);
}
}Example
class MyServant extends MySlices.MyServant {
@operation()
async myOperation() {
const result = await doSomeStuff();
return result;
}
}handleDispatchException(handler: IceErrorHandler): RemoveIceErrorHandler
Add a hook for handling uncaught dispatch errors.
Ice.Warn.Dispatch
must be turned on.
Default error logging is disabled if custom handler is assigned.
Example
const removeHandler = handleDispatchException((error, context, current) => {
const {requestId, operation, id} = current;
console.error(error, {
...context,
iceRequestId: requestId,
iceOperation: operation,
iceIdentity: Ice.identityToString(id)
});
});