Skip to content

Commit

Permalink
Fix. translations: /ko/docs/advanced/select
Browse files Browse the repository at this point in the history
  • Loading branch information
MinByeongDon committed Mar 22, 2024
1 parent 947388d commit a24989f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions website/docs/advanced/select/select/codegen.dart
Expand Up @@ -19,11 +19,15 @@ User example(ExampleRef ref) => User()
class ConsumerExample extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
// {@template watch}
// Instead of writing:
// String name = ref.watch(provider).firstName!;
// We can write:
// {@endtemplate}
String name = ref.watch(exampleProvider.select((it) => it.firstName));
// {@template note}
// This will cause the widget to only listen to changes on "firstName".
// {@endtemplate}

return Text('Hello $name');
}
Expand Down
4 changes: 4 additions & 0 deletions website/docs/advanced/select/select_async/codegen.dart
Expand Up @@ -16,11 +16,15 @@ final userProvider = FutureProvider(
/* SNIPPET START */
@riverpod
Object? example(ExampleRef ref) async {
// {@template watch}
// Wait for a user to be available, and listen to only the "firstName" property
// {@endtemplate}
final firstName = await ref.watch(
userProvider.selectAsync((it) => it.firstName),
);

// {@template todo}
// TODO use "firstName" to fetch something else
// {@endtemplate}
}
/* SNIPPET END */
@@ -1,5 +1,6 @@
---
title: 성능 최적화하기
version: 1
---

import { AutoSnippet } from "/src/components/CodeSnippet";
Expand Down Expand Up @@ -27,7 +28,13 @@ import selectAsync from "/docs/advanced/select/select_async";
이렇게 하면 `ref.watch`는 더 이상 전체 객체를 반환하지 않고 선택된 프로퍼티만 반환합니다.
그리고 consumer/provider는 이제 선택된 프로퍼티가 변경되는 경우에만 다시 빌드됩니다.

<AutoSnippet {...select} />
<AutoSnippet
{...select}
translations={{
watch: " // 아래처럼 작성하는 대신:\n // String name = ref.watch(provider).firstName!;\n // 이렇게 작성할 수 있습니다:",
note: " // 그러면 위젯이 'firstName'에 대한 변경 사항만 수신하게 됩니다."
}}
/>

:::info
`select`는 원하는 횟수만큼 호출할 수 있습니다.
Expand Down Expand Up @@ -58,6 +65,7 @@ import selectAsync from "/docs/advanced/select/select_async";
<AutoSnippet
{...selectAsync}
translations={{
watch: " // user를 사용할 수 있을 때까지 기다렸다가 \"firstName\" 속성만 수신합니다."
watch: " // user를 사용할 수 있을 때까지 기다렸다가 \"firstName\" 속성만 수신합니다.",
todo: " // TODO 다른 항목을 가져오기위해 \"firstName\"을 사용합니다."
}}
/>
1 change: 0 additions & 1 deletion website/src/documents_meta.js
Expand Up @@ -424,7 +424,6 @@ export const outdatedTranslations = [
{"countryCode":"ja","id":"providers/state_notifier_provider","englishPath":"/docs/providers/state_notifier_provider"},
{"countryCode":"ja","id":"providers/state_provider","englishPath":"/docs/providers/state_provider"},
{"countryCode":"ja","id":"providers/stream_provider","englishPath":"/docs/providers/stream_provider"},
{"countryCode":"ko","id":"advanced/select","englishPath":"/docs/advanced/select"},
{"countryCode":"ko","id":"case_studies/cancel","englishPath":"/docs/case_studies/cancel"},
{"countryCode":"ko","id":"case_studies/pull_to_refresh","englishPath":"/docs/case_studies/pull_to_refresh"},
{"countryCode":"ko","id":"concepts/about_code_generation","englishPath":"/docs/concepts/about_code_generation"},
Expand Down

0 comments on commit a24989f

Please sign in to comment.