Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7066b56

Browse files
committed
okan adds finally implementation on promise
1 parent891b8af commit7066b56

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

‎package.json‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"redux-ts",
3-
"version":"2.2.0",
3+
"version":"2.3.0",
44
"description":"Utils to define redux reducer/action in typescript",
55
"main":"lib/index.js",
66
"typings":"lib/src/index.d.ts",
@@ -31,18 +31,20 @@
3131
"tags": [
3232
"react",
3333
"redux",
34-
"typesctipt",
34+
"typescript",
35+
"ts",
3536
"action",
3637
"reducer",
37-
"decorator"
38+
"async"
3839
],
3940
"keywords": [
4041
"react",
4142
"redux",
42-
"typesctipt",
43+
"typescript",
44+
"ts",
4345
"action",
4446
"reducer",
45-
"decorator"
47+
"async"
4648
],
4749
"dependencies": {
4850
"react":"^15.3.1",
@@ -68,4 +70,4 @@
6870
"react":"^0.14.0 || ^15.0.0-0",
6971
"redux":"^2.0.0 || ^3.0.0"
7072
}
71-
}
73+
}

‎src/utils/actionHelpers.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import'ts-helpers'
2+
import"./promiseHelpers"
23

34

45
exporttypeNullableDispatch=Redux.Dispatch<any>|void;
@@ -18,4 +19,8 @@ export abstract class AsyncAction extends SyncAction implements Promise<Nullable
1819
catch(onrejected?:(reason:any)=>NullableDispatch|PromiseLike<NullableDispatch>):Promise<NullableDispatch>{
1920
returnthis.promise.catch(onrejected);
2021
}
21-
}
22+
23+
finally(onfulfilled?:(value?:NullableDispatch,isSuccess?:boolean)=>any|PromiseLike<NullableDispatch>):Promise<NullableDispatch>{
24+
returnthis.promise.finally(onfulfilled);
25+
}
26+
}

‎src/utils/promiseHelpers.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
interfacePromise<T>{
2+
finally<TResult>(onfulfilled?:(value?:T,isSuccess?:boolean)=>TResult|PromiseLike<TResult>):Promise<TResult>;
3+
}
4+
5+
Promise.prototype['finally']=functionfinallyPolyfill<TResult>(callback:(value?:any,isSuccess?:boolean)=>TResult|PromiseLike<TResult>){
6+
varconstructor=this.constructor;
7+
8+
returnthis.then(function(value:any){
9+
returnconstructor.resolve(callback(value,true)).then(function(){
10+
returnvalue;
11+
});
12+
},function(reason:any){
13+
returnconstructor.resolve(callback(reason,false)).then(function(){
14+
throwreason;
15+
});
16+
});
17+
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp