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

Commit155b35d

Browse files
authored
Cleanup redundant stack frames (#125)
Drawing on the learnings from#124, this removes some unnecessary anonymous functions from the modern Satchel dispatch pipeline.
1 parentd76863e commit155b35d

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

‎src/applyMiddleware.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ export default function applyMiddleware(...middleware: Middleware[]) {
1313
}
1414

1515
functionapplyNextMiddleware(middleware:Middleware,next:DispatchFunction):DispatchFunction{
16-
returnactionMessage=>middleware(next,actionMessage);
16+
returnmiddleware.bind(null,next);
1717
}

‎src/dispatcher.ts‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ export function dispatch(actionMessage: ActionMessage) {
1919
}
2020

2121
letdispatchWithMiddleware=getGlobalContext().dispatchWithMiddleware||finalDispatch;
22-
23-
transaction(()=>{
24-
dispatchWithMiddleware(actionMessage);
25-
});
22+
transaction(dispatchWithMiddleware.bind(null,actionMessage));
2623
}
2724

2825
exportfunctionfinalDispatch(actionMessage:ActionMessage):void|Promise<void>{
@@ -32,12 +29,12 @@ export function finalDispatch(actionMessage: ActionMessage): void | Promise<void
3229
if(subscribers){
3330
letpromises:Promise<any>[]=[];
3431

35-
subscribers.forEach(subscriber=>{
32+
for(constsubscriberofsubscribers){
3633
letreturnValue=subscriber(actionMessage);
3734
if(returnValue){
3835
promises.push(returnValue);
3936
}
40-
});
37+
}
4138

4239
if(promises.length){
4340
returnpromises.length==1 ?promises[0] :Promise.all(promises);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp