Rxjs: Observable.from prioritizes array over observable symbol

Created on 2 Jun 2018  路  4Comments  路  Source: ReactiveX/rxjs

Bug Report

Current Behavior
When an object that is "array like" and has Observable Symbol, Observable.from uses array like Observable.from mechanism before the Observable Symbol interop.

This is a problem in Microstates because the Observable Symbol provides the proper mechanism to make a Microstate observable. Treating it like an array does something very funky.

Reproduction

const assert = require('assert');
const { from } = require('rxjs');
const Microstates = require('microstates').default;

let ms = Microstates.from([{hello: 'world'}]);

from(ms).subscribe(next => assert(next[0], 'Should have an array with one item'))

Expected behavior
I would expect the Observable Symbol interop to be used before any other.

Environment

  • Runtime: [Node & Browsers]
  • RxJS version:
  • 6.1

Possible Solution
Check for Observable Symbol interop before all other options.

Related https://github.com/microstates/microstates.js/issues/130

bug

Most helpful comment

@benlesh I can create a PR if it helps.

All 4 comments

I agree. I think this is a bug. If it's not an RxJS Observable, we should check to see if it has the interop point before checking other types. Thanks, @taras.

cc @kwonoj

@benlesh I can create a PR if it helps.

@taras feel freely go for it.

@kwonoj here you go

Was this page helpful?
0 / 5 - 0 ratings

Related issues

samherrmann picture samherrmann  路  3Comments

OliverJAsh picture OliverJAsh  路  3Comments

Zzzen picture Zzzen  路  3Comments

matthewwithanm picture matthewwithanm  路  4Comments

LittleFox94 picture LittleFox94  路  3Comments