Skip to content

Commit

Permalink
fix(lib): use get/set for events prop of element strategies
Browse files Browse the repository at this point in the history
This will allow for late binding of the property in the wrapped strategies
  • Loading branch information
gund committed Jul 8, 2020
1 parent 0c628bf commit 5324893
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { ComponentRef, Injector, Type } from '@angular/core';
import { NgElementStrategy, NgElementStrategyFactory } from '@angular/elements';
import {
NgElementStrategy,
NgElementStrategyEvent,
NgElementStrategyFactory,
} from '@angular/elements';
import {
ElementBoundaryNgElementStrategy,
ElementBoundaryNgElementStrategyFactory,
} from 'ngx-element-boundary';
import { Observable } from 'rxjs';

import {
DefaultNgElementStrategyFactory,
Expand Down Expand Up @@ -59,7 +64,13 @@ export class DefaultElementBoundaryNgElementStrategyOptionsDefault
*/
export class DefaultElementBoundaryNgElementStrategy
implements ElementBoundaryNgElementStrategy {
events = this.defaultStrategy.events;
get events() {
return this.defaultStrategy.events;
}

set events(events: Observable<NgElementStrategyEvent>) {
this.defaultStrategy.events = events;
}

private options: DefaultElementBoundaryNgElementStrategyOptionsDefault;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Injector } from '@angular/core';
import { NgElementStrategy, NgElementStrategyFactory } from '@angular/elements';
import { of, Subject } from 'rxjs';
import {
NgElementStrategy,
NgElementStrategyEvent,
NgElementStrategyFactory,
} from '@angular/elements';
import { Observable, of, Subject } from 'rxjs';
import { take, takeUntil, timeoutWith } from 'rxjs/operators';

import {
Expand Down Expand Up @@ -63,7 +67,13 @@ export class CrossBoundaryNgElementStrategyOptionsDefault
* To disable the timeout you may set it to `0` (zero, number)
*/
export class CrossBoundaryNgElementStrategy implements NgElementStrategy {
events = this.baseStrategy.events;
get events() {
return this.baseStrategy.events;
}

set events(events: Observable<NgElementStrategyEvent>) {
this.baseStrategy.events = events;
}

private elementBoundaryService: ElementBoundaryService = this.hookableInjector.get(
ElementBoundaryService,
Expand Down

0 comments on commit 5324893

Please sign in to comment.