mirror of
https://github.com/chsakell/aspnet-core-signalr-angular.git
synced 2025-12-22 17:27:48 +00:00
feed table added
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
import { FeedService } from '../shared/services/feed.service';
|
||||
import { Match } from '../shared/interfaces';
|
||||
import { Match, Feed } from '../shared/interfaces';
|
||||
import { DataService } from '../shared/services/data.service';
|
||||
import { ConnectionState } from '../shared/interfaces';
|
||||
|
||||
@@ -41,12 +41,29 @@ export class HomeComponent implements OnInit {
|
||||
this.dataService.getMatches()
|
||||
.subscribe((res: Match[]) => {
|
||||
self.matches = res;
|
||||
// Listen for match score updates...
|
||||
self.feedService.updateMatch.subscribe(
|
||||
match => {
|
||||
for(var i=0; i< self.matches.length; i++)
|
||||
{
|
||||
for (var i = 0; i < self.matches.length; i++) {
|
||||
if (self.matches[i].Id === match.Id) {
|
||||
self.matches[i] = match;
|
||||
self.matches[i].HostScore = match.HostScore;
|
||||
self.matches[i].GuestScore = match.GuestScore;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Listen for subscribed feed updates..
|
||||
self.feedService.addFeed.subscribe(
|
||||
feed => {
|
||||
console.log(feed);
|
||||
for (var i = 0; i < self.matches.length; i++) {
|
||||
if (self.matches[i].Id === feed.MatchId) {
|
||||
if (!self.matches[i].Feeds) {
|
||||
console.log('initializing for match ' + self.matches[i].Id);
|
||||
self.matches[i].Feeds = new Array<Feed>();
|
||||
}
|
||||
self.matches[i].Feeds.unshift(feed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user