pixelbits pixelbits - 11 months ago 40
Javascript Question

rxjs how do you emit a single value

I would like to emit a single value.

According to this post, the following should be valid:

var requestStream = Rx.Observable.just('https://api.github.com/users');

However, this does not work.
is not defined.

Has it been deprecated? Is there something that I can use instead?

Answer Source

A lot of the stuff is tucked away in: import 'rxjs/Rx'; You might try Observable.of for a single value.

This works for me (plunker):

import {Component} from 'angular2/core';
import {Observable} from 'rxjs/Observable';
import 'rxjs/Rx';

  selector: 'my-app',
  providers: [],
  template: `
      <h2>Hello {{test | async}}</h2>     
  directives: []
export class App {
    test: Observable<any> = Observable.of("I'm an observable");
    constructor() {