Skip to content

Commit c9b5bd3

Browse files
committed
fix(context-onhandler-to-events): support "appContext"
1 parent 046112c commit c9b5bd3

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {UseCase} from "almin";
2+
export default class AsyncUseCase extends UseCase {
3+
// 1. call onWillExecuteEachUseCase
4+
execute() {
5+
// 2. call onDispatch
6+
this.dispatch({ type : "start" });
7+
return Promise.resolve().then(() => {
8+
// does async function
9+
}).then(() => {
10+
// 4. call onCompleteEachUseCase
11+
});
12+
}
13+
// 3. call onDidExecuteEachUseCase
14+
}
15+
// listen on*
16+
appContext.onWillExecuteEachUseCase((payload, meta) => {});
17+
appContext.onDispatch((payload, meta) => {});
18+
appContext.onDidExecuteEachUseCase((payload, meta) => {});
19+
appContext.onCompleteEachUseCase((payload, meta) => {});
20+
appContext.onErrorDispatch((payload, meta) => {});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {UseCase} from "almin";
2+
export default class AsyncUseCase extends UseCase {
3+
// 1. call onWillExecuteEachUseCase
4+
execute() {
5+
// 2. call onDispatch
6+
this.dispatch({ type : "start" });
7+
return Promise.resolve().then(() => {
8+
// does async function
9+
}).then(() => {
10+
// 4. call onCompleteEachUseCase
11+
});
12+
}
13+
// 3. call onDidExecuteEachUseCase
14+
}
15+
// listen on*
16+
appContext.events.onWillExecuteEachUseCase((payload, meta) => {});
17+
appContext.events.onDispatch((payload, meta) => {});
18+
appContext.events.onDidExecuteEachUseCase((payload, meta) => {});
19+
appContext.events.onCompleteEachUseCase((payload, meta) => {});
20+
appContext.events.onErrorDispatch((payload, meta) => {});

scripts/context-onhandler-to-events.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module.exports = function transformer(file, api) {
4747
if (callee.object.type !== "Identifier") {
4848
return false;
4949
}
50-
return callee.object.name === "context";
50+
return callee.object.name === "context" || callee.object.name === "appContext";
5151
};
5252

5353
return j(file.source)

0 commit comments

Comments
 (0)