Skip to content

Commit 579792d

Browse files
committed
#155 contextのbind/unbindは内部でのみ利用に変更
1 parent d5a9082 commit 579792d

3 files changed

Lines changed: 14 additions & 35 deletions

File tree

src/application/Application/usecase/ApplicationGotoViewUseCase.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ vi.mock("../../../domain/callback/service/CallbackService", () => ({
3838
execute: vi.fn().mockResolvedValue(undefined)
3939
}));
4040

41+
vi.mock("../../Context/usecase/ContextBindUseCase", () => ({
42+
execute: vi.fn().mockResolvedValue(null)
43+
}));
44+
45+
vi.mock("../../Context/service/ContextUnbindService", () => ({
46+
execute: vi.fn().mockResolvedValue(undefined)
47+
}));
48+
4149
describe("ApplicationGotoViewUseCase Test", () =>
4250
{
4351
let mockApplication: any;
@@ -55,8 +63,6 @@ describe("ApplicationGotoViewUseCase Test", () =>
5563

5664
root = new MovieClip();
5765
mockContext = new Context(root);
58-
mockContext.unbind = vi.fn().mockResolvedValue(undefined);
59-
mockContext.bind = vi.fn().mockResolvedValue(null);
6066

6167
$setContext(mockContext);
6268
$setConfig({
@@ -84,6 +90,7 @@ describe("ApplicationGotoViewUseCase Test", () =>
8490
{
8591
const { execute: applicationQueryStringParserService } = await import("../service/ApplicationQueryStringParserService");
8692
const { execute: requestUseCase } = await import("../../../infrastructure/Request/usecase/RequestUseCase");
93+
const { execute: contextBindUseCase } = await import("../../Context/usecase/ContextBindUseCase");
8794

8895
vi.mocked(applicationQueryStringParserService).mockReturnValue({
8996
name: "home",
@@ -94,9 +101,8 @@ describe("ApplicationGotoViewUseCase Test", () =>
94101

95102
await execute(mockApplication, "home");
96103

97-
expect(mockContext.unbind).toHaveBeenCalled();
98104
expect(mockApplication.currentName).toBe("home");
99-
expect(mockContext.bind).toHaveBeenCalledWith("home");
105+
expect(contextBindUseCase).toHaveBeenCalledWith(mockContext, "home");
100106
});
101107

102108
it("execute test case2: navigation with response data", async () =>

src/application/Application/usecase/ApplicationGotoViewUseCase.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { execute as responseRemoveVariableUseCase } from "../../../infrastructur
1010
import { execute as applicationQueryStringParserService } from "../service/ApplicationQueryStringParserService";
1111
import { execute as requestUseCase } from "../../../infrastructure/Request/usecase/RequestUseCase";
1212
import { execute as callbackService } from "../../../domain/callback/service/CallbackService";
13+
import { execute as contextUnbindService } from "../../Context/service/ContextUnbindService";
14+
import { execute as contextBindUseCase } from "../../Context/usecase/ContextBindUseCase";
1315

1416
/**
1517
* @description 指定されたパス、もしくはURLのクラスを起動
@@ -45,7 +47,7 @@ export const execute = async (application: Application, name: string = ""): Prom
4547
* Unbind the View and ViewModel of the current screen
4648
*/
4749
const context = $getContext();
48-
await context.unbind();
50+
await contextUnbindService(context);
4951

5052
/**
5153
* 前の画面で取得したレスポンスデータを初期化
@@ -114,7 +116,7 @@ export const execute = async (application: Application, name: string = ""): Prom
114116
* ViewとViewModelを起動
115117
* Start View and ViewModel
116118
*/
117-
const view = await context.bind(application.currentName);
119+
const view = await contextBindUseCase(context, application.currentName);
118120

119121
/**
120122
* コールバック設定があれば実行

src/application/Context.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import type { View } from "../view/View";
22
import type { ViewModel } from "../view/ViewModel";
33
import type { Sprite } from "@next2d/display";
4-
import { execute as contextUnbindService } from "./Context/service/ContextUnbindService";
5-
import { execute as contextBindUseCase } from "./Context/usecase/ContextBindUseCase";
64

75
/**
86
* @description メインコンテキスト、ViewとViewModelのunbind、bindをコントロールします。
@@ -65,31 +63,4 @@ export class Context
6563
{
6664
return this._$root;
6765
}
68-
69-
/**
70-
* @description ViewクラスをrootのSpriteにアタッチします。
71-
* Attach the View class to the root Sprite.
72-
*
73-
* @param {string} name
74-
* @return {Promise<View>}
75-
* @method
76-
* @public
77-
*/
78-
async bind (name: string): Promise<View>
79-
{
80-
return await contextBindUseCase(this, name);
81-
}
82-
83-
/**
84-
* @description ViewとViewModelのバインドを解除します。
85-
* Unbinds View and ViewModel.
86-
*
87-
* @return {Promise<void>}
88-
* @method
89-
* @public
90-
*/
91-
async unbind (): Promise<void>
92-
{
93-
await contextUnbindService(this);
94-
}
9566
}

0 commit comments

Comments
 (0)