Skip to content

Commit 409987b

Browse files
committed
clean up build
1 parent 5bf27de commit 409987b

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

Tests/A+ Spec/2.2.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ public void _when_promise1_is_rejected_with_no_value_in_catch()
348348

349349
new Promise<object>((res, rej) => rej(new Exception()))
350350
.Catch(_ => {})
351-
.Then(() => callbackInvoked = true);
351+
.Then((x) => callbackInvoked = true);
352352

353353
Assert.True(callbackInvoked);
354354
}

src/Promise.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using RSG.Promises;
1+
using RSG.Promises;
22
using System;
33
using System.Collections.Generic;
44
using System.Linq;
@@ -427,19 +427,19 @@ IPromiseBase IPromiseBase.WithName(string name)
427427
/// <summary>
428428
/// Handle errors for the promise.
429429
/// </summary>
430-
public IPromise Catch(Action<Exception> onRejected)
430+
public IPromise<PromisedT> Catch(Action<Exception> onRejected)
431431
{
432-
var resultPromise = new Promise();
432+
var resultPromise = new Promise<PromisedT>();
433433
resultPromise.WithName(Name);
434434

435-
Action<PromisedT> resolveHandler = _ => resultPromise.Resolve();
435+
Action<PromisedT> resolveHandler = _ => resultPromise.Resolve(default(PromisedT));
436436

437437
Action<Exception> rejectHandler = ex =>
438438
{
439439
try
440440
{
441441
onRejected(ex);
442-
resultPromise.Resolve();
442+
resultPromise.Resolve(default(PromisedT));
443443
}
444444
catch(Exception cbEx)
445445
{

Promise_Base.cs renamed to src/Promise_Base.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
3+
using RSG.Exceptions;
34
using RSG.Promises;
45

56
namespace RSG
@@ -158,6 +159,20 @@ public interface IPromiseInfo
158159
string Name { get; }
159160
}
160161

162+
public struct ProgressHandler
163+
{
164+
/// <summary>
165+
/// Callback fn.
166+
/// </summary>
167+
public Action<float> callback;
168+
169+
/// <summary>
170+
/// The promise that is rejected when there is an error while invoking the handler.
171+
/// </summary>
172+
public IRejectable rejectable;
173+
}
174+
175+
161176
public abstract class Promise_Base : IPromiseInfo
162177
{
163178
/// <summary>
@@ -197,7 +212,7 @@ public Promise_Base()
197212

198213
if (Promise.EnablePromiseTracking)
199214
{
200-
Promise.pendingPromises.Add(this);
215+
Promise.PendingPromises.Add(this);
201216
}
202217
}
203218

@@ -273,15 +288,15 @@ public void Reject(Exception ex)
273288

274289
if (CurState != PromiseState.Pending)
275290
{
276-
throw new ApplicationException("Attempt to reject a promise that is already in state: " + CurState + ", a promise can only be rejected when it is still in state: " + PromiseState.Pending);
291+
throw new PromiseStateException("Attempt to reject a promise that is already in state: " + CurState + ", a promise can only be rejected when it is still in state: " + PromiseState.Pending);
277292
}
278293

279294
rejectionException = ex;
280295
CurState = PromiseState.Rejected;
281296

282297
if (Promise.EnablePromiseTracking)
283298
{
284-
Promise.pendingPromises.Remove(this);
299+
Promise.PendingPromises.Remove(this);
285300
}
286301

287302
InvokeRejectHandlers(ex);

0 commit comments

Comments
 (0)