-
Notifications
You must be signed in to change notification settings - Fork 345
Change: Configをasyncに #1618
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
Change: Configをasyncに #1618
Conversation
Hiroshiba
left a comment
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.
なるほど・・・・・・。Discordで悩まれてたのこれなんですね。
正直なところ結構煩雑性が跳ね上がってる印象を受けましたが、どうすべきかパッとわかんないですね・・・・。
getConfigをasyncにすると、もうどうしてもいたるところでasync汚染が発生してしまうので、これをなんとか同期処理にする方法をいくつか考えました 😇
こういうところがプログラマーの腕の見せ所なので頑張りたい。
- initializeされた後に
Let configに代入する
let config
initializeConfig().then((obj) => {config = obj})みたいな感じ。configがinializeするのを待つ関数もいるかも。
-
electron用に通常BaseConfigを、async用にBasicAsyncConfigを作る
正直問題の先送り感が。 -
let configにしてapp.on("ready")の最初でconfig = await getConfig
| const engineManager = new EngineManager({ | ||
| config, |
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.
configをDIする形じゃなくなってますね~
今まではBaseConfig相当のものがあればOKだったのが、ElectronConfigに依存する形になったので、以前よりも密結合になってしまった感じです。
|
1と3、多分configがundefinedかのチェックが必要になる気がします。 ちょっと考えてみました:
async waitForSave() {
while (this.counter > 0) {
// 別のPromiseにスレッドを譲る:Pythonのawait asyncio.sleep(0)みたいな
await new Promise((resolve) => setTimeout(resolve, 0))
}
}
|
|
@sevenc-nanashi 良い感じだと思いました!! 雰囲気がLockだなと感じました。vvppManagerで導入したAsyncLockが使えるかも。 Configの役割がわかってきた気がします。どっちかというと名前はConfigManagerのが良いかもと思いました。
本当はそうなんですよね・・・。winもundefinedチェックしてないしまあ良いかな〜とか思ってました。 Line 102 in a80def6
|
|
んー、lockというよりはRc/Arcだと思います。 |
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.
configの取り回しはかなりいい感じになったと思います!!
終了シーケンスに関してちょっとお願いがあったので細かいコメントさせていただきました 🙇
ちょっと自分用のメモにタスクリスト書かせてください!
- 設定保存待機処理が入る場合は終了シーケンスを書き換える
|
レビューを反映しました。Config -> ConfigManagerもやってもいいかも? |
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!!
コメント良い感じですね!!!
Config -> ConfigManager
良いと思います!
その場合dataが真のConfigかもですね。(ConfigTypeでも良さそう)
あとはまあクラス説明ドキュメントがちょっと変わるくらいかなぁ。
変えた場合は再度reviewもらえれば 🙏
📝 終了シーケンス書き換え
|
ConfigからConfigManagerにしました。 |
Hiroshiba
left a comment
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!!
型がConfigManagerになってる変数や引数の名前はconfigManagerにしてengineManagerと合わせても良いかもですね
終了シーケンス図の書き足しをするついでにこっちで書き換えさせていただきます!!
|
マージします! |
内容
Configをasyncにします。主にスマホ版のためです(
@capacitor/preferencesはasyncしかない)関連 Issue
スクリーンショット・動画など
(なし)
その他
(なし)