> For the complete documentation index, see [llms.txt](https://vytautas.gitbook.io/ng-state/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vytautas.gitbook.io/ng-state/other-information/best-practices.md).

# Best practices

and recommendations

## Here you will find some recommendations in order to not miss use this library&#x20;

* Actions should be used **ONLY for manipulating state**. They should not cntain business logic or call other services
* Try to avoid absolute paths in @InjectStore decorator because
  * &#x20;it might lead to wrong architecture of your project
  * paths might become long
  * paths can start to overlap
* Direct store usage, when injecting into service or components via constructor, should not be common, rather exceptional case. e.g: you might have some shared data like `userData` stored in the root of you state and you want to access it from everywhere. But for this case I recommend to have some `authService` and with method `getUserData` rather than keep repeating same code (DRY principle)

```typescript
getUserData() {
    let userData;
    
    this.store
        .select<UserData>(['userData'])
        .pipe(take(1))
        .select(state => userData = state);
        
    return userData;
}
```

* User Smart and dumb components
* User @InjectStore decorator **ONLY** on smart components
* Entire *application* with *smart components* should **reflect structure of state as** **close as possible.**&#x20;

![State Structure](https://2483127471-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La0zIK2BFiXY6Eig7aR%2F-LvzGgJAd2Iiw05Bzxas%2F-LvzdQSoFILBLdK4ZRGc%2FState%20flow%20\(1\).png?alt=media\&token=0fe67b36-6542-4e31-91c3-0ed8cd3cfec5)
