diff --git a/package.json b/package.json index 61d689be30f591..54c8f10c45d620 100644 --- a/package.json +++ b/package.json @@ -180,7 +180,6 @@ "script-loader": "0.7.2", "semver": "^5.5.0", "style-loader": "0.19.0", - "symbol-observable": "^1.2.0", "tar": "2.2.0", "tinygradient": "0.3.0", "tinymath": "0.2.1", diff --git a/src/core/lib/kbn_internal_native_observable/index.js b/src/core/lib/kbn_internal_native_observable/index.js index 4b6a56c9062f0d..504ddc1e342972 100644 --- a/src/core/lib/kbn_internal_native_observable/index.js +++ b/src/core/lib/kbn_internal_native_observable/index.js @@ -1,4 +1,4 @@ -import symbolObservable from 'symbol-observable'; +import { observable as SymbolObservable } from 'rxjs/internal/symbol/observable'; // This is a fork of the example implementation of the TC39 Observable spec, // see https://github.com/tc39/proposal-observable. @@ -256,7 +256,7 @@ export class Observable { return new Subscription(observer, this._subscriber); } - [symbolObservable]() { return this } + [SymbolObservable]() { return this } // == Derived == @@ -267,7 +267,7 @@ export class Observable { if (x == null) throw new TypeError(x + " is not an object"); - let method = getMethod(x, symbolObservable); + let method = getMethod(x, SymbolObservable); if (method) { diff --git a/src/core/lib/kbn_observable/__tests__/observable_rxjs.test.ts b/src/core/lib/kbn_observable/__tests__/observable_rxjs.test.ts new file mode 100644 index 00000000000000..1d17b0b28e3e6b --- /dev/null +++ b/src/core/lib/kbn_observable/__tests__/observable_rxjs.test.ts @@ -0,0 +1,37 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { from, of } from 'rxjs'; +import { isObservable } from '../lib/is_observable'; +import { Observable } from '../observable'; + +// Test that rxjs observable and kbn-observable are interoperable. +describe('interoperability', () => { + it('understood by rxjs of kbn-observables', () => { + const obs = Observable.of([1, 2, 3]); + expect(() => { + from(obs); + }).not.toThrowError(TypeError); + }); + + it('understood by kbn-observable of rxjs observables', () => { + const rxobs = of([1, 2, 3]); + expect(isObservable(rxobs)).toBeTruthy(); + }); +}); diff --git a/src/core/lib/kbn_observable/lib/is_observable.ts b/src/core/lib/kbn_observable/lib/is_observable.ts index ef1999e840534e..23c7d80d49d5a7 100644 --- a/src/core/lib/kbn_observable/lib/is_observable.ts +++ b/src/core/lib/kbn_observable/lib/is_observable.ts @@ -17,8 +17,9 @@ * under the License. */ +import { observable as SymbolObservable } from 'rxjs/internal/symbol/observable'; import { Observable } from '../observable'; export function isObservable(x: any): x is Observable { - return x !== null && typeof x === 'object' && x[Symbol.observable] !== undefined; + return x !== null && typeof x === 'object' && x[SymbolObservable] !== undefined; }