Skip to content
This repository has been archived by the owner on Dec 25, 2018. It is now read-only.

Commit

Permalink
Finalized Promise module structure and separated out final version of…
Browse files Browse the repository at this point in the history
… LazyPromise class.

This introduces smart defer methods which for LazyPromises do not trigger the underlying promise unless the consumer calls 'then'.
  • Loading branch information
electricessence committed May 27, 2016
1 parent 4da16f8 commit 83f81c4
Show file tree
Hide file tree
Showing 69 changed files with 1,293 additions and 665 deletions.
2 changes: 1 addition & 1 deletion bower.json
@@ -1,6 +1,6 @@
{
"name": "typescript-dotnet",
"version": "2.16.6",
"version": "2.17.0",
"ignore": [
".bowercc",
".gitignore",
Expand Down
16 changes: 16 additions & 0 deletions dist/amd/System/Promises/LazyPromise.d.ts
@@ -0,0 +1,16 @@
/*!
* @author electricessence / https://github.com/electricessence/
* Licensing: MIT
*/
import { Promise, PromiseBase } from "./Promise";
export declare class LazyPromise<T> extends Promise<T> {
private _resolver;
constructor(_resolver: Promise.Executor<T>);
protected _onDispose(): void;
private _onThen();
thenSynchronous<TResult>(onFulfilled: Promise.Fulfill<T, TResult>, onRejected?: Promise.Reject<TResult>): PromiseBase<TResult>;
thenThis(onFulfilled: (v?: T) => any, onRejected?: (v?: any) => any): PromiseBase<T>;
delayFromNow(milliseconds?: number): PromiseBase<T>;
delayAfterResolve(milliseconds?: number): PromiseBase<T>;
}
export default LazyPromise;
6 changes: 6 additions & 0 deletions dist/amd/System/Promises/LazyPromise.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/amd/System/Promises/LazyPromise.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 2 additions & 12 deletions dist/amd/System/Promises/Promise.d.ts
Expand Up @@ -42,23 +42,15 @@ export declare abstract class Resolved<T> extends Resolvable<T> {
}
export declare class Promise<T> extends Resolvable<T> {
private _waiting;
constructor(resolver?: Promise.Executor<T>);
constructor(resolver?: Promise.Executor<T>, forceSynchronous?: boolean);
thenSynchronous<TResult>(onFulfilled: Promise.Fulfill<T, TResult>, onRejected?: Promise.Reject<TResult>): PromiseBase<TResult>;
thenThis(onFulfilled: (v?: T) => any, onRejected?: (v?: any) => any): PromiseBase<T>;
protected _onDispose(): void;
protected _resolvedCalled: boolean;
resolveUsing(resolver: Promise.Executor<T>, throwIfSettled?: boolean): void;
resolveUsing(resolver: Promise.Executor<T>, forceSynchronous?: boolean, throwIfSettled?: boolean): void;
resolve(result?: T, throwIfSettled?: boolean): void;
reject(error: any, throwIfSettled?: boolean): void;
}
export declare class LazyPromise<T> extends Promise<T> {
private _resolver;
constructor(_resolver: Promise.Executor<T>);
protected _onDispose(): void;
private _onThen();
thenSynchronous<TResult>(onFulfilled: Promise.Fulfill<T, TResult>, onRejected?: Promise.Reject<TResult>): PromiseBase<TResult>;
thenThis(onFulfilled: (v?: T) => any, onRejected?: (v?: any) => any): PromiseBase<T>;
}
export declare module Promise {
enum State {
Pending = 0,
Expand All @@ -85,8 +77,6 @@ export declare module Promise {
function resolve(): PromiseBase<void>;
function resolve<T>(value: T | PromiseLike<T>): PromiseBase<T>;
function reject<T>(reason: T): PromiseBase<T>;
function lazy<T>(resolver: Promise.Executor<T>): LazyPromise<T>;
function wrap<T>(target: PromiseLike<T>): PromiseBase<T>;
function createFrom<T, TResult>(then: Then<T, TResult>): PromiseBase<T>;
function pending<T>(resolver?: Promise.Executor<T>): Promise<T>;
}

0 comments on commit 83f81c4

Please sign in to comment.