Skip to content

Commit

Permalink
Merge pull request #208 from derekdai/reactivity-doc
Browse files Browse the repository at this point in the history
fix typos. add a section for assigning new value to reactivity variables with `set()`
  • Loading branch information
Ethosa authored Dec 5, 2023
2 parents 75786b1 + 1f0612b commit 84a825b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
19 changes: 15 additions & 4 deletions examples/website/src/docs/reactivity.nim
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ component Reactivity:

tP: {translate"This example shows how to interact with reactive variables in the routes of the SPA application."}

component CodeBlock("nim", nimSpaReacitivity1, "nim_spa_reactivity_1")
component CodeBlock("nim", nimSpaReactivity1, "nim_spa_reactivity_1")

tP:
{translate"As you can see in the above code example, a special syntax is used to call the "}
Expand All @@ -29,11 +29,11 @@ component Reactivity:

tP: {translate"The example below shows all the other examples of creating reactive variables."}

component CodeBlock("nim", nimSpaReacitivity3, "nim_spa_reactivity_3")
component CodeBlock("nim", nimSpaReactivity3, "nim_spa_reactivity_3")

tP: {translate"Let's look at an example of working with sequences."}

component CodeBlock("nim", nimSpaReacitivity2, "nim_spa_reactivity_2")
component CodeBlock("nim", nimSpaReactivity2, "nim_spa_reactivity_2")

tP:
{translate"In the example above, the "}
Expand Down Expand Up @@ -95,4 +95,15 @@ component Reactivity:

tP: {translate"Speaking of built-in frequently used functions, it is worth noting that they can be used together with ordinary values. Let's look at the following example."}

component CodeBlock("nim", nimSpaReacitivity4, "nim_spa_reactivity_4")
component CodeBlock("nim", nimSpaReactivity4, "nim_spa_reactivity_4")

tP:
{translate"To specify a new value for reactivity variables, you can use "}
tCode: "set()"
{translate". For example, you can use "}
tCode: "set()"
{translate" to replace the entire "}
tCode: "seq[T]"
{translate" in one go."}

component CodeBlock("nim", nimSpaReactivity5, "nim_spa_reactivity_5")
16 changes: 12 additions & 4 deletions examples/website/src/ui/code.nim
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ appRoutes "app":
Test(x = 15)
Test(x = 20)
"""
nimSpaReacitivity1* = """import happyx
nimSpaReactivity1* = """import happyx
var x = remember 0
Expand All @@ -791,7 +791,7 @@ appRoutes "app":
@click:
x->inc()
"""
nimSpaReacitivity2* = """import happyx
nimSpaReactivity2* = """import happyx
var x = remember newSeq[int]()
Expand All @@ -801,7 +801,7 @@ appRoutes "app":
@click:
x->add(x.len())
"""
nimSpaReacitivity3* = """import happyx
nimSpaReactivity3* = """import happyx
var
x = remember newSeq[int]()
Expand All @@ -810,7 +810,7 @@ var
w: State[string] = remember "Hello"
"""
nimSpaReacitivity4* = """import happyx
nimSpaReactivity4* = """import happyx
var
x = remember 0
Expand All @@ -826,6 +826,14 @@ echo x # x is 100 and again, x is State[int]
str &= ", world!"
echo str # Hello, world!, but str is State[string]
"""
nimSpaReactivity5* = """import happyx
var
x = remember seq[int].default
x.set @[1, 2, 3]
"""
nimSsrMongoDb1* = """import
happyx, # import happyx web framework
Expand Down
24 changes: 24 additions & 0 deletions examples/website/src/ui/translations.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,30 @@ translatable:
"zh" -> "说到内置的常用函数,值得注意的是它们可以与普通值一起使用。让我们看看下面的例子。"
"fr" -> "En parlant des fonctions intégrées fréquemment utilisées, il est important de noter qu'elles peuvent être utilisées avec des valeurs ordinaires. Jetons un coup d'œil à l'exemple suivant."
"ko" -> "내장된 자주 사용되는 함수에 대해 언급할 때 주목할 점은 이러한 함수들이 일반 값과 함께 사용될 수 있다는 것입니다. 다음 예제를 살펴보겠습니다."
"To specify a new value for reactivity variables, you can use ":
"ru" -> "Чтобы указать новое значение для реактивных переменных, вы можете использовать "
"ja" -> "リアクティビティ変数の新しい値を指定するには、"
"zh" -> "要为响应变量指定新值,可以使用 "
"fr" -> "Pour spécifier une nouvelle valeur pour les variables réactives, vous pouvez utiliser "
"ko" -> "반응성 변수에 대한 새로운 값을 지정하려면 "
". For example, you can use ":
"ru" -> ". Например, вы можете использовать "
"ja" -> ". たとえば、"
"zh" -> ". 例如,您可以使用 "
"fr" -> ". Par exemple, vous pouvez utiliser "
"ko" -> ". 예를 들어 "
" to replace the entire ":
"ru" -> " чтобы заменить весь "
"ja" -> " 全体を置き換えるには "
"zh" -> " 以替换整个 "
"fr" -> " pour remplacer l'ensemble du "
"ko" -> " 전체를 교체하려면 "
" in one go.":
"ru" -> " за один раз."
"ja" -> " 全体を一度に置き換えるためには "
"zh" -> " 。一次性替换整个 "
"fr" -> " en une seule fois."
"ko" -> " 를 사용할 수 있습니다."
"Database access 📦":
"ru" -> "Доступ к базе данных 📦"
"ja" -> "データベースアクセス 📦"
Expand Down

0 comments on commit 84a825b

Please sign in to comment.