My latest creation is a service called ContactService.
type contactPredicate = (contact: Contact) => boolean;
type contactLike = Contact | string | SelectedContact;
@Injectable()
export class ContactService {
private selectedContactId: string = '';
public selectedContactSubject: BehaviorSubject<contactLike>;
public get SelectedContact(): contactLike {
const contact: Contact = this.contactList.find((v) => v.Id === this.selectedContactId);
return contact ? contact : null;
}
public set SelectedContact(value: contactLike) {
this.selectedContactId = typeof value === 'string' ? value as string : value.Id;
this.selectedContactSubject.next(this.findContact(this.selectedContactId));
}
constructor() {
this.selectedContactSubject = new BehaviorSubject<Contact>(this.findContact(this.selectedContactId));
}
}
Inserting this service into another service named "FileService" results in the following code snippet.
import { ContactService } from './contact.service';
@Injectable()
export class FileService {
constructor(
private httpServiceProvider: HttpServiceProvider,
private userService: UserService,
private contactService: ContactService) {
}
// More functionality goes here
}
A SharedModule file showcases the configuration setup for SignalR and other declarations.
// Content of SharedModule.ts
// More code goes here
Details about the AppModule with key components imported such as BrowserModule, CoreModule, and DashboardSharedModule.
// Details from AppModule.ts
// Content goes here
The DashboardSharedModule contains essential components like HeaderComponent, MessageSectionComponent, ConversationSectionComponent, etc.
// Contents inside DashboardSharedModule.ts
// More details included here
An error message related to provider issues between the services has been encountered while arranging both services in the same folder.
PS - Due to clarity purposes, some code snippets have been excluded.