2
0
mirror of https://github.com/esiur/esiur-js.git synced 2026-04-03 21:48:21 +00:00
This commit is contained in:
2021-03-10 01:25:20 +03:00
parent ca2b89540a
commit a08519bde8
55 changed files with 4190 additions and 6679 deletions

View File

@@ -28,11 +28,22 @@ import ExceptionCode from './ExceptionCode.js';
export default class AsyncException extends Error
{
constructor()
{
super();
this.raised = false;
}
constructor(type, code, message)
{
super();
if (type instanceof AsyncException) {
this.raise(type.type, type.code, type.message);
} else if (type instanceof Error) {
this.raise(1, 0, type.message);
} else if (type != undefined){
this.raise(type, code, message);
} else {
this.raised = false;
}
}
raise(type, code, message)
{

View File

@@ -94,14 +94,16 @@ export default class AsyncReply extends Promise
this.ready = true;
for(var i = 0; i < this.callbacks.length; i++)
this.callbacks[i](result, this);
this.callbacks[i](result, this);
return this;
}
triggerError(type, code, message)
{
if (this.ready)
return;
return this;
if (type instanceof AsyncException)
this.exception.raise(type.type, type.code, type.message);
@@ -113,18 +115,24 @@ export default class AsyncReply extends Promise
else
for(var i = 0; i < this.errorCallbacks.length; i++)
this.errorCallbacks[i](this.exception, this);
return this;
}
triggerProgress(type, value, max)
{
for(var i = 0; i < this.progressCallbacks.length; i++)
this.progressCallbacks[i](type, value, max, this);
return this;
}
triggerChunk(value)
{
for(var i = 0; i < this.chunkCallbacks.length; i++)
this.chunkCallbacks[i](value, this);
return this;
}
constructor(result)

View File

@@ -30,5 +30,9 @@ export default //const ExceptionCode =
SetPropertyDenied: 27,
ReadOnlyProperty: 28,
GeneralFailure: 29,
AddToStoreFailed: 30
AddToStoreFailed: 30,
NotAttached: 31,
AlreadyListened: 32,
AlreadyUnlistened: 33,
NotListenable: 34
};