Skip to content

Commit 4a39bbb

Browse files
authored
Merge pull request #210 from Georift/window-context-fix
Fix rejecting rxjs Observables created from other window contexts
2 parents 92e21d2 + d2d81ce commit 4a39bbb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Unreleased
2+
### Fixes
3+
* Fixed mistakenly rejecting Observables from other contexts
4+
15
## 0.0.48
26
### Fixes
37
* Fixed `ac-circle-desc` radius changing.

src/angular-cesium/components/ac-layer/ac-layer.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,21 @@ export class AcLayerComponent implements OnInit, OnChanges, AfterContentInit, On
252252
const acForArr = this.acFor.split(' ');
253253
this.observable = this.context[acForArr[3]];
254254
this.entityName = acForArr[1];
255-
if (!this.observable || !(this.observable instanceof Observable)) {
255+
if (!this.isObservable(this.observable)) {
256256
throw new Error('ac-layer: must initailize [acFor] with rx observable, instead received: ' + this.observable);
257257
}
258258

259259
this.layerService.context = this.context;
260260
this.layerService.setEntityName(this.entityName);
261261
}
262262

263+
/** Test for a rxjs Observable */
264+
private isObservable(obj: any): boolean {
265+
/* check via duck-typing rather than instance of
266+
* to allow passing between window contexts */
267+
return obj && typeof obj.subscribe === 'function'
268+
}
269+
263270
ngAfterContentInit(): void {
264271
this.init();
265272
}

0 commit comments

Comments
 (0)