diff --git a/spec/observables/from-spec.ts b/spec/observables/from-spec.ts index 4917927b85..4add2e298e 100644 --- a/spec/observables/from-spec.ts +++ b/spec/observables/from-spec.ts @@ -1,6 +1,7 @@ import { expect } from 'chai'; import { TestScheduler } from 'rxjs/testing'; -import { asyncScheduler, of, from, Observable, asapScheduler, Observer } from 'rxjs'; +import { asyncScheduler, of, from, Observable, asapScheduler, Observer, observable, Subject } from 'rxjs'; +import { first } from 'rxjs/operators'; // tslint:disable:no-any declare const asDiagram: any; @@ -118,5 +119,26 @@ describe('from', () => { ); expect(nextInvoked).to.equal(false); }); + it(`should accept a function`, (done) => { + const subject = new Subject(); + const handler = (...args: any[]) => subject.next(...args); + handler[observable] = () => subject; + let nextInvoked = false; + + from((handler as any)).pipe(first()).subscribe( + (x) => { + nextInvoked = true; + expect(x).to.equal('x'); + }, + (x) => { + done(new Error('should not be called')); + }, + () => { + expect(nextInvoked).to.equal(true); + done(); + } + ); + handler('x'); + }); } }); diff --git a/src/internal/util/isArrayLike.ts b/src/internal/util/isArrayLike.ts index 15da7a50f4..6f634d4d9f 100644 --- a/src/internal/util/isArrayLike.ts +++ b/src/internal/util/isArrayLike.ts @@ -1 +1 @@ -export const isArrayLike = ((x: any): x is ArrayLike => x && typeof x.length === 'number'); \ No newline at end of file +export const isArrayLike = ((x: any): x is ArrayLike => x && typeof x.length === 'number' && typeof x !== 'function'); \ No newline at end of file