为什么80%的码农都做不了架构师?>>>
//新建服务
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';
@Injectable({providedIn: 'root'
})
export class ChatMsgService {private msgSource=new Subject
}
//引入服务并发送信息
import { Injectable } from '@angular/core';
import {StorageService} from '../service/storage.service';
import { Observable, of,Subject } from 'rxjs';
import {ChatMsg} from '../chat/class/chat-msg';
import {ChatMsgService} from './chat-msg.service';
@Injectable({providedIn: 'root'
})export class SocketService {ws:any;private chatMsg=new Subject
//监听服务constructor(private socket:SocketService,private request:RequestService,private srv: ɵcd,private chatMsgService:ChatMsgService){}pages:Pages=new Pages(0,0,0,0);ngOnInit() {this.getFriendsList();this.chatMsgService.msgSend$.subscribe((msg)=>{console.log(msg);})}