How to use the rxjs/Observable.Observable.of function in rxjs

To help you get started, we’ve selected a few rxjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DSI-HUG / dejajs-components / src / common / core / item-list / item-list.service.ts View on Github external
if (this._cache.groupedList && this._cache.groupedList.length) {
            return Observable.of(this._cache.groupedList);
        } else if (!this.groupInfos || this.groupInfos.length === 0) {
            return Observable.of(this.items)
                .do((items) => this._cache.groupedList = items);
        } else if (this.items) {
            return this.getGroupedList$(this.items)
                .do((groupedList) => {
                    if (this._cache.groupedList && this._cache.groupedList.length && this._cache.groupedList !== groupedList) {
                        // New grouped list
                        this.invalidateViewCache();
                    }
                    this._cache.groupedList = groupedList;
                });
        } else {
            return Observable.of([]);
        }
    }
github hasadna / open_pension / client / src / app / modules / blog / effects / post.spec.ts View on Github external
describe('PostEffects', () => {
  let effects: PostEffects;
  const actions: Observable = Observable.of('');

  beforeEach(() => {
    TestBed.configureTestingModule({
      providers: [
        PostEffects,
        provideMockActions(() => actions),
        // other providers
        PostService,
        {
          provide: Http,
          useFactory: (mockBackend, options) => {
            return new Http(mockBackend, options);
          },
          deps: [MockBackend, BaseRequestOptions]
        },
        MockBackend,
github Texera / texera / core / new-gui / src / app / workspace / service / operator-metadata / stub-operator-metadata.service.ts View on Github external
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';

import { mockOperatorMetaData } from './mock-operator-metadata.data';
import { OperatorMetadata, OperatorSchema } from '../../types/operator-schema.interface';

import '../../../common/rxjs-operators';
import { IOperatorMetadataService } from './operator-metadata.service';

@Injectable()
export class StubOperatorMetadataService implements IOperatorMetadataService {

  private operatorMetadataObservable = Observable
    .of(mockOperatorMetaData)
    .shareReplay(1);

  constructor() { }

  public getOperatorSchema(operatorType: string): OperatorSchema {
    const operatorSchema = mockOperatorMetaData.operators.find(schema => schema.operatorType === operatorType);
    if (! operatorSchema) {
      throw new Error(`can\'t find operator schema of type ${operatorType}`);
    }
    return operatorSchema;
  }

  public getOperatorMetadata(): Observable {
    return this.operatorMetadataObservable;
  }
github patrickmichalina / fusebox-angular-universal-starter / src / client / app / not-found / not-found.component.ts View on Github external
.catch(err => {
        if (err.code === 'PERMISSION_DENIED') {
          this.rs.setStatus(401)
          return Observable.of({
            content: 'unauthorized'
          })
        } else {
          this.rs.setError()
          return Observable.of({
            content: err || 'server error'
          })
        }
      }))
github ffxiv-teamcraft / ffxiv-teamcraft / src / app / pages / custom-links / custom-links / custom-links.component.ts View on Github external
getName(link: CustomLink): Observable {
        return Observable.of(link.redirectTo)
            .mergeMap(uri => {
                if (uri.startsWith('list/')) {
                    return this.listService.get(uri.replace('list/', ''));
                } else if (uri.startsWith('workshop/')) {
                    return this.workshopService.get(uri.replace('workshop/', ''));
                }
                return Observable.of(null)
            })
            .catch(() => {
                return this.customLinkService.remove(link.$key).map(() => null);
            })
            .filter(val => val !== null)
            .map(element => element.name);
    }
github skycoin / skycoin-web / src / app / services / app.service.ts View on Github external
      .catch(() => Observable.of(ConnectionError.UNAVAILABLE_BACKEND));
  }
github Hughp135 / angular-5-chat-app / src / app / components / view-server / view-server.component.spec.ts View on Github external
const channel: ChatChannel = {
    name: 'name',
    _id: '123',
    server_id: '345',
  };
  const server: ChatServer = {
    name: 'serv',
    _id: '345',
    owner_id: 'abc',
  };

  const fakeRoute = {
    data: Observable.of({
      state: {
        channel: Observable.of(channel),
        server: Observable.of(server),
        me: Observable.of({ _id: 'abc' }),
      },
    }),
  };

  const apiServiceMock = {
    post: jasmine.createSpy().and.callFake((url: string) => {
      if (url.includes('error-generic')) {
        const error = { status: 500 };
        return Observable.throw(error);
      } else if (url.includes('error-with-message')) {
        const error = { status: 400, error: { error: 'test' } };
        return Observable.throw(error);
      }
      return Observable.of({}).delay(1);
    }),