I currently have an ECMAScript Observable that is compliant with specifications, specifically sourced from the wonka library. I am facing challenges in converting this type of observable to an rxjs 6 observable.
It appears that this conversion was possible with rxjs 5. I attempted the following:
import { pipe, toObservable, fromArray } from 'wonka';
import { from } from 'rxjs';
...
from(
pipe(
fromArray([1, 2, 3]),
toObservable
)
);
Upon testing this code in the browser, I encountered this error message:
ERROR TypeError: You provided an invalid object where a stream was expected.
You can provide an Observable, Promise, Array, or Iterable.
and also received this error:
Argument of type 'observableT<any>' is not assignable to parameter of type 'ObservableInput<any>'
In order to work around this issue, I managed to convert it to a zen-observable by following these steps:
npm i zen-observable
npm i --save-dev @types/zen-observable
import { from } from 'zen-observable';
...
getObservable(): Observable<any> {
return from(
pipe(
fromArray([1, 2, 3]),
toObservable
) as any) as any;
}
However, utilizing a zen-observable does not offer the same capabilities and functionalities as an rxjs observable.
If you have insights on how to properly convert this to an rxjs observable, I would greatly appreciate your help.
Thank you, J