-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: modelSkeleton #38
Conversation
akastercomcom
commented
Sep 18, 2023
- model class생성
- modelController skeleton생성. ainetwork와 통신하는 ain skeleton 구현 완료 후 작업 이어 하겠습니다.
- ainize에 model명령어 추가
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model controller를 Global Instance로 관리할지 model마다 새 instance를 할당할지 명확히 결정되어야 할 것 같습니다.
src/controllers/modelController.ts
Outdated
@@ -0,0 +1,65 @@ | |||
export default class ModelController { | |||
instance: ModelController | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static instance ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
적용했습니다. 추가로 코드 수정했습니다.
src/model.ts
Outdated
|
||
constructor(modelName: string) { | ||
this.modelName = modelName; | ||
this.modelController = new ModelController(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 방식으로 호출하면 ModelController 안에 instance가 없어도 될 것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new를 하면 modelController에서 instance를 넘깁니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modelController의 constructor에서 instance가 이미 생성되었다면, if를 통해 instance를 넘깁니다.
src/controllers/modelController.ts
Outdated
private static instance: ModelController | undefined; | ||
constructor() { | ||
if(ModelController.instance) return ModelController.instance; | ||
ModelController.instance = this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
첫 생성 시에 this가 정상적으로 할당될 수 있는지 잘 모르겠습니다.
static인 instance는 constructor로 초기화하지 않고 static getInstance() 함수를 통해서 받아올 수 있도록 할 수 있을 것 같습니다.
class ModelController {
private static instance: ModelController;
static getInstance() {
if (!ModelController.instance)
ModelController.instance = new ModelContoller();
return ModelController.instance;
}
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 경우에 instance는 ModelController.getInstance() 로 가져올 수 있습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 좋은 것 같습니다.
수정했습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Thanks!
Thanks! now merged |