Skip to content

Commit

Permalink
docs: links
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed May 15, 2024
1 parent 947bf65 commit a82d235
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/docs/cookbook/composables.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

## Option Stores

<MasteringPiniaLink
href="https://masteringpinia.com/lessons/using-composables-in-option-stores"
title="Using Composables in Option Stores"
/>

When defining an option store, you can call a composable inside of the `state` property:

```ts
Expand All @@ -27,6 +32,11 @@ Here are some examples of composables that cannot be used in an option stores (b

## Setup Stores

<MasteringPiniaLink
href="https://masteringpinia.com/lessons/using-composables-in-setup-stores"
title="Using Composables in Setup Stores"
/>

On the other hand, when defining a setup store, you can use almost any composable since every property gets discerned into state, action, or getter:

```ts
Expand Down
5 changes: 5 additions & 0 deletions packages/docs/cookbook/testing.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Testing stores

<MasteringPiniaLink
href="https://masteringpinia.com/lessons/introduction-to-testing-stores"
title="Learn how to test stores"
/>

Stores will, by design, be used at many places and can make testing much harder than it should be. Fortunately, this doesn't have to be the case. We need to take care of three things when testing stores:

- The `pinia` instance: Stores cannot work without it
Expand Down
10 changes: 10 additions & 0 deletions packages/docs/zh/cookbook/composables.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

## Option Stores %{#option-stores}%

<MasteringPiniaLink
href="https://masteringpinia.com/lessons/using-composables-in-option-stores"
title="Using Composables in Option Stores"
/>

当定义一个 option store 时,你可以在 `state` 属性中调用组合式函数:

```ts
Expand All @@ -27,6 +32,11 @@ export const useAuthStore = defineStore('auth', {

## Setup Stores %{#setup-stores}%

<MasteringPiniaLink
href="https://masteringpinia.com/lessons/using-composables-in-setup-stores"
title="Using Composables in Setup Stores"
/>

另外,当定义一个 setup store 时,你几乎可以使用任何组合式函数,因为每一个属性都会被辨别为 state 、action 或者 getter:

```ts
Expand Down
5 changes: 5 additions & 0 deletions packages/docs/zh/cookbook/testing.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# store 测试 %{#testing-stores}%

<MasteringPiniaLink
href="https://masteringpinia.com/lessons/introduction-to-testing-stores"
title="Learn how to test stores"
/>

从设计上来说,许多地方都会使用 store,所以可能比正常情况更难测试。但幸运的是,这不一定是真的。在测试 store 时,我们需要注意三件事:

- `pinia` 实例:没有它,store 不能正常工作
Expand Down

0 comments on commit a82d235

Please sign in to comment.