Skip to content

Commit

Permalink
Use official documentation links
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkamyshev committed Aug 16, 2024
1 parent 8e39331 commit b7f99eb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
25 changes: 2 additions & 23 deletions apps/website/docs/factories/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ outline: [2, 3]

In Effector's world any factory is a function that returns a set of [_Stores_](https://effector.dev/docs/api/effector/store), [_Events_](https://effector.dev/en/api/effector/event/) or [_Effects_](https://effector.dev/docs/api/effector/effect). It's a way to encapsulate some logic and reuse it in different places.

If your application has any unit-tests or meant to be rendered on the server (SSR) factories have to be added to `factories` field in config of [`effector/babel-plugin`](https://effector.dev/docs/api/effector/babel-plugin/) or [`@effector/swc-plugin`](https://github.com/effector/swc-plugin). The reasons of this limitation are described in [this article](https://farfetched.pages.dev/recipes/sids.html).
If your application has any unit-tests or meant to be rendered on the server (SSR) factories have to be added to `factories` field in config of [`effector/babel-plugin`](https://effector.dev/docs/api/effector/babel-plugin/) or [`@effector/swc-plugin`](https://effector.dev/en/api/effector/swc-plugin/). The reasons of this limitation are described in [this article](https://effector.dev/en/explanation/sids/).

In real world it is easy to add any third-party library that uses factories to the config because it has an exact import path. But adding factories from your own code is a bit more complicated. There are no automatic ways to validate that all factories are added to the config. This library is solving this problem: just add `@withease/factories` to the config and use it to create and invoke factories.

Expand All @@ -32,28 +32,7 @@ npm install @withease/factories

:::

Second, you need to add `@withease/factories` to the config of [`effector/babel-plugin`](https://effector.dev/docs/api/effector/babel-plugin/) or [`@effector/swc-plugin`](https://github.com/effector/swc-plugin):

::: code-group

```json [effector/babel-plugin]
{
"plugins": [["effector/babel-plugin"]]
}
```

```json [@effector/swc-plugin]
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"experimental": {
"plugins": [["@effector/swc-plugin"]]
}
}
}
```

:::
Second, you need to setup [`effector/babel-plugin`](https://effector.dev/docs/api/effector/babel-plugin/) or [`@effector/swc-plugin`](https://effector.dev/en/api/effector/swc-plugin/). Please follow the instructions in the corresponding documentation.

That's it! Now you can use `@withease/factories` to create and invoke factories across your application.

Expand Down
2 changes: 1 addition & 1 deletion apps/website/docs/factories/motivation.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Let us elaborate on these problems.

## Controlling that factories are invoked correctly

In Effector's ecosystem, all factories [have to be added to the code-transformation plugin's config](https://farfetched.pages.dev/recipes/sids.html). But it is really easy to forget to add a factory to the config after creating it. Effector's plugin will not throw an error in this case, but the factory will not work correctly in case of SSR.
In Effector's ecosystem, all factories [have to be added to the code-transformation plugin's config](https://effector.dev/en/explanation/sids/). But it is really easy to forget to add a factory to the config after creating it. Effector's plugin will not throw an error in this case, but the factory will not work correctly in case of SSR.

In case of using this library, you have to remember only one thing: all factories have to be created using `createFactory` function from `@withease/factories` library. The result of this function is not callable, so you will get an error if you try to invoke it directly.

Expand Down

0 comments on commit b7f99eb

Please sign in to comment.