mirror of
https://github.com/chsakell/aspnet-core-signalr-angular.git
synced 2025-12-22 17:27:48 +00:00
hide show subscribe buttons
This commit is contained in:
@@ -19,13 +19,16 @@
|
||||
<span class="label label-success">{{match.Type}}</span>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-default btn-md" (click)="subscribe()">
|
||||
<button type="button" class="btn btn-default btn-md" (click)="subscribe()" *ngIf="!subscribed">
|
||||
Subscribe to feed
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger btn-md" (click)="unsubscribe()" *ngIf="subscribed">
|
||||
Unubscribe
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><button type="button" class="btn btn-default btn-xs">Send</button></td>
|
||||
<tr *ngIf="subscribed">
|
||||
<td><button type="button" class="btn btn-default btn-md">Send</button></td>
|
||||
<td><input type="text" class="form-control" placeholder="Type message.." /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -10,6 +10,7 @@ import { FeedService } from '../services/feed.service';
|
||||
export class MatchComponent implements OnInit {
|
||||
|
||||
@Input() match: Match;
|
||||
subscribed: boolean;
|
||||
|
||||
constructor(private feedService: FeedService) { }
|
||||
|
||||
@@ -17,6 +18,12 @@ export class MatchComponent implements OnInit {
|
||||
|
||||
subscribe() {
|
||||
console.log(this.match.Id);
|
||||
this.subscribed = true;
|
||||
this.feedService.subscribeToFeed(this.match.Id);
|
||||
}
|
||||
|
||||
unsubscribe() {
|
||||
this.subscribed = false;
|
||||
this.feedService.unsubscribeToFeed(this.match.Id);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,8 @@ export interface FeedClient {
|
||||
}
|
||||
|
||||
export interface FeedServer {
|
||||
subscribe(matchId: number) : void;
|
||||
subscribe(matchId: number): void;
|
||||
unsubscribe(matchId: number): void;
|
||||
}
|
||||
|
||||
export enum ConnectionState {
|
||||
|
||||
@@ -121,4 +121,8 @@ export class FeedService {
|
||||
public subscribeToFeed(matchId: number) {
|
||||
this.server.subscribe(matchId);
|
||||
}
|
||||
|
||||
public unsubscribeToFeed(matchId: number) {
|
||||
this.server.unsubscribe(matchId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user