Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Commit

Permalink
refactor(readme): update getSlice doc
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsisexistence committed Jun 16, 2019
1 parent 7f164e6 commit 36b6182
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ There are several ways to get a slice:
```typescript
export const appSlice: Slice<AppNotes> = createRoot<AppNotes>(routes, APP_HUB_KEY);
```

- **@Sliced decorator**. Apply that decorator on component's prop. You should pass key or slice name (example at the top)
```typescript
@Component({
Expand All @@ -296,7 +297,20 @@ export class HeaderComponent {
@Sliced('about')
private about: Slice<AboutNotes>;
}
```

- **getSlice** - is a function, that works as decorator. Essentially it is created as an alternative to decorator
```typescript
@Component({
...
})
export class HeaderComponent {
// getting slice by key
private app = getSlice<AppNotes, AppChildNotes>(APP_HUB_KEY);

// getting slice by slice name
private about = getSlice<AboutNotes>('about');
}
```

- **Union** - almost the same, as first way with slice const. That one creates a union from any quantity of slices.
Expand Down
14 changes: 14 additions & 0 deletions package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ There are several ways to get a slice:
```typescript
export const appSlice: Slice<AppNotes> = createRoot<AppNotes>(routes, APP_HUB_KEY);
```

- **@Sliced decorator**. Apply that decorator on component's prop. You should pass key or slice name (example at the top)
```typescript
@Component({
Expand All @@ -296,7 +297,20 @@ export class HeaderComponent {
@Sliced('about')
private about: Slice<AboutNotes>;
}
```

- **getSlice** - is a function, that works as decorator. Essentially it is created as an alternative to decorator
```typescript
@Component({
...
})
export class HeaderComponent {
// getting slice by key
private app = getSlice<AppNotes, AppChildNotes>(APP_HUB_KEY);

// getting slice by slice name
private about = getSlice<AboutNotes>('about');
}
```

- **Union** - almost the same, as first way with slice const. That one creates a union from any quantity of slices.
Expand Down

0 comments on commit 36b6182

Please sign in to comment.