mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-28 13:18:49 +01:00
feat: docs app
This commit is contained in:
parent
713aff561e
commit
2129689f98
203 changed files with 15927 additions and 5 deletions
25
docs/app/@theme/services/iframe-communicator.service.ts
Normal file
25
docs/app/@theme/services/iframe-communicator.service.ts
Normal 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),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue