feat: update npm packages

This commit is contained in:
Sergey Andrievskiy 2021-08-06 18:48:35 +03:00 committed by d.strigo
parent f6d9ec88ad
commit 7a22737611
321 changed files with 19716 additions and 84 deletions

View file

@ -0,0 +1,25 @@
import { Inject, Injectable } from '@angular/core';
import { Observable, fromEvent as observableFromEvent } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { NB_WINDOW } from '@nebular/theme';
@Injectable()
export class NgxIframeCommunicatorService {
constructor(@Inject(NB_WINDOW) private window) {
}
public send(payload: any, target: Window = this.window.parent) {
if (target !== this.window) {
target.postMessage(payload, '*');
}
}
public receive(id: string): Observable<any> {
return observableFromEvent(this.window, 'message')
.pipe(
filter((msg: any) => msg.data && msg.data.id === id),
map((msg: any) => msg.data),
);
}
}