A set of utilities that makes using ZeroC ICE with JS easier.
Installation
npm install --save ice-utils
API
toPromise(icePromise: Ice.Promise): Promise
Turn Ice promise to normal one. Useful with async
/await
because await
ing
Ice promises leads to infinite loops.
Example
{ const icePromise = myPrx; const result = await ; 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
MyServant @ { return ; }
Example
MyServant @ async { const result = await ; 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 = ;