Imagine that we have 3 components and one of them has some function which I want to use in other components. All these components are on the same level (siblings).
file1.ts
export class ComponentWithFunction() {
function getData() {
console.log('data has been fetched');
}
}
file2.ts
export class ComponentA() {
// here I want to have possibility to use getData
}
file3.ts
export class ComponentB() {
// here I want to have possibility to use getData
}
What should I do to have an access to getData function from other component? I know that I can create SharedService and Inject it into specified components but is there any other way like using static functions or something like that ?
Thank you