Skip to content
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

♻️ 5章の修正案 #9

Closed
wants to merge 6 commits into from
Closed

Conversation

chippy-ao
Copy link
Contributor

概要

  • 基本的に機能面での修正はありません。
  • UIで取得はstream、更新はrepositoryになっていた部分が気になったため、そこを修正しました。
    • Repositoryをclass化し、Providerに渡しました。
    • updateは、FutureProvider化させてUIから扱う階層をStreamProviderと揃えました。

コメント

  • 普段はドメインモデルやusecase組んで、stateやcontrollerを用意してとか、インターフェース挟んでDIとかしてるのですが、あまりにも4章からかけ離れるので、やめました。笑
  • Freezedがあれば、copyWithで楽なので、モデル(state)の操作とリポジトリの更新を呼ぶNotifierProviderにしますが、今回はそうではないため、FutureProviderがぽっと出てくる感じになっています。

@cloudflare-pages
Copy link

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 767482d
Status: ✅  Deploy successful!
Preview URL: https://511ba1b7.tic-tac-toe-handson.pages.dev
Branch Preview URL: https://topic-chapter5-idea.tic-tac-toe-handson.pages.dev

View logs

import 'package:tic_tac_toe_handson/model/tic_tac_toe.dart';
import 'package:tic_tac_toe_handson/repository/tic_tac_toe_repository.dart';

final getTicTacToeProvider = AutoDisposeStreamProvider<TicTacToe>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

いつも.autoDisposeを指定していてAutoDispose~Provider初めて知りました!ありがとうございます!:pray:

@okaryo
Copy link
Contributor

okaryo commented Oct 9, 2023

cherry-pickして取り込みました!ありがとうございます!
#5

@okaryo okaryo closed this Oct 9, 2023
@okaryo okaryo deleted the topic/chapter5_idea branch October 9, 2023 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants