Skip to content

Commit

Permalink
Fix the CounterDisplayComponent example in README.md. Release version…
Browse files Browse the repository at this point in the history
… 1.0.3
  • Loading branch information
Gopakumar Nair authored and Gopakumar Nair committed Nov 28, 2024
1 parent 4ac6789 commit c2379ba
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 20 deletions.
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ export class CounterControlComponent {
### Listen to state changes
Use the injected StateMachine to observe state changes and render UI accordingly.
```typescript
import {Component, OnDestroy} from '@angular/core';
import {Component} from '@angular/core';
import {StateKeyConstants} from '../constants/state-keys.constants';
import {AsyncPipe} from '@angular/common';
import {Observable, Subscription} from 'rxjs';
import {Observable} from 'rxjs';
import {StateMachine} from '@state-management/ngx-state-machine';

@Component({
Expand All @@ -179,20 +179,14 @@ import {StateMachine} from '@state-management/ngx-state-machine';
imports: [AsyncPipe],
template: ` <p>counter value is: {{(counter$|async)}}</p> `
})
export class CounterDisplayComponent implements OnDestroy {
export class CounterDisplayComponent {
protected counter$:Observable<number> | undefined;
protected subscription: Subscription;

constructor(private stateMachine: StateMachine) {
// Use the injected StateMachine to observe state changes.
this.counter$ = this.stateMachine.observe(StateKeyConstants.COUNTER_KEY);
}

ngOnDestroy(): void {
if(this.subscription)
this.subscription.unsubscribe();
}

}
```

Expand Down
12 changes: 3 additions & 9 deletions dist/ngx-state-machine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ export class CounterControlComponent {
### Listen to state changes
Use the injected StateMachine to observe state changes and render UI accordingly.
```typescript
import {Component, OnDestroy} from '@angular/core';
import {Component} from '@angular/core';
import {StateKeyConstants} from '../constants/state-keys.constants';
import {AsyncPipe} from '@angular/common';
import {Observable, Subscription} from 'rxjs';
import {Observable} from 'rxjs';
import {StateMachine} from '@state-management/ngx-state-machine';

@Component({
Expand All @@ -179,20 +179,14 @@ import {StateMachine} from '@state-management/ngx-state-machine';
imports: [AsyncPipe],
template: ` <p>counter value is: {{(counter$|async)}}</p> `
})
export class CounterDisplayComponent implements OnDestroy {
export class CounterDisplayComponent {
protected counter$:Observable<number> | undefined;
protected subscription: Subscription;

constructor(private stateMachine: StateMachine) {
// Use the injected StateMachine to observe state changes.
this.counter$ = this.stateMachine.observe(StateKeyConstants.COUNTER_KEY);
}

ngOnDestroy(): void {
if(this.subscription)
this.subscription.unsubscribe();
}

}
```

Expand Down
2 changes: 1 addition & 1 deletion dist/ngx-state-machine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@state-management/ngx-state-machine",
"version": "1.0.2",
"version": "1.0.3",
"description": "An Angular wrapper for simple-state-machine library, integrates the simple-state-machine with Angular’s dependency injection system",
"main": "bundles/state-management-ngx-state-machine.umd.js",
"module": "fesm2015/state-management-ngx-state-machine.js",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@state-management/ngx-state-machine",
"version": "1.0.2",
"version": "1.0.3",
"description": "An Angular wrapper for simple-state-machine library, integrates the simple-state-machine with Angular’s dependency injection system",
"main": "dist/ngx-state-machine/bundles/ngx-state-machine.umd.js",
"module": "dist/ngx-state-machine/esm2015/index.js",
Expand Down

0 comments on commit c2379ba

Please sign in to comment.