Skip to content

Commit

Permalink
docs: Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
finom committed May 31, 2023
1 parent 9c7870d commit 2f61bda
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,24 @@ export class RootStore extends Use0 {
}
```
You can create `initStore` method to handle that automatically.
```ts
export class RootStore extends Use0 {
// ...
constructor() {
super();
this.initStore();
}

initStore = () => {
for(const member of Object.values(this)) {
if(typeof member.init === 'function') member.init(this);
}
}
}
```
This way to architect the store makes possible to export sub-stores and their methods separate from the root store.
```ts
Expand Down Expand Up @@ -412,7 +430,7 @@ const store = _store as RootStore;
console.log(store); // now it's OK
```
To fix Eslint error about `_` symbol in the variable name you can modify the rule:
To fix ESLint error about `_` symbol in the variable name you can modify the rule:
```ts
'@typescript-eslint/naming-convention': [2, { leadingUnderscore: true }]
Expand Down

0 comments on commit 2f61bda

Please sign in to comment.