How to use the rxjs.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 Ninja-Squad / globe42 / frontend / src / app / person-files / person-files.component.spec.ts View on Github external
it('should upload a file', () => {
    // create component with 1 file
    const personFileService = TestBed.get(PersonFileService);
    spyOn(personFileService, 'list').and.returnValues(of([files[0]]), of(files));

    const fakeEvents = new Subject();
    spyOn(personFileService, 'create').and.returnValues(fakeEvents);

    const fixture = TestBed.createComponent(PersonFilesComponent);
    fixture.detectChanges();

    // trigger change
    const fileChangeEvent = {
      target: {
        files: [{
          name: files[1].name
        }]
      }
    } as any;
github w11k / ngx-componentdestroyed / src / tslint / BadComponent.ts View on Github external
import {Component, OnDestroy, OnInit} from "@angular/core";
import {of} from "rxjs";
import {map, takeUntil} from "rxjs/operators";
import {untilComponentDestroyed} from "../index";

class SomeClass {
    subscribe() {
    }
}

@Component({})
class BadComponent implements OnInit, OnDestroy {

    observable = of(1);
    stop = of(1);

    ngOnInit() {
        // Error
        this.observable.pipe(
            map(i => i),
            takeUntil(this.stop),
            map(i => i),
        ).subscribe();

        // Error
        this.observable.pipe(
            map(i => i),
            untilComponentDestroyed(this),
            map(i => i),
        ).subscribe();
github sourcegraph / sourcegraph / client / browser / src / shared / components / SymbolsDropdownContainer.tsx View on Github external
// 1) emit a 'loading...' message if fetching the symbol results takes more than half a second
        // 2) emit the actual results
        const incrementalResults = merge(
            of(LOADING).pipe(
                delay(500),
                takeUntil(symbolResults)
            ),

            symbolResults
        )

        if (queryText.length === 1) {
            // The user has likely just typed a brand-new autocomplete
            // query. Clear out the results from any previous symbol fetch requests.
            return concat(of(undefined), incrementalResults)
        }

        return incrementalResults
    }
github ReactiveX / rxjs / src / internal / operators / derived / combineAll-spec.ts View on Github external
testScheduler.run(({ hot, cold, expectObservable, expectSubscriptionsTo }) => {
      const left =  hot('--a--^--b--c--#', undefined, 'jenga');
      const leftSubs =       '^        !';
      const right = hot('-----^----------d--e--f--|');
      const rightSubs =      '^        !';
      const expected =       '---------#';

      const result = of(left, right).pipe(combineAll());

      expectObservable(result).toBe(expected, null, 'jenga');
      expectSubscriptionsTo(left).toBe(leftSubs);
      expectSubscriptionsTo(right).toBe(rightSubs);
    });
  });
github DSpace / dspace-angular / src / app / shared / mydspace-actions / workflowitem / workflowitem-actions.component.spec.ts View on Github external
'dc.contributor.author': [
      {
        language: 'en_US',
        value: 'Smith, Donald'
      }
    ],
    'dc.date.issued': [
      {
        language: null,
        value: '2015-06-26'
      }
    ]
  }
});
const rd = createSuccessfulRemoteDataObject(item);
mockObject = Object.assign(new WorkflowItem(), { item: observableOf(rd), id: '1234', uuid: '1234' });

describe('WorkflowitemActionsComponent', () => {
  beforeEach(async(() => {
    TestBed.configureTestingModule({
      imports: [
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useClass: MockTranslateLoader
          }
        })
      ],
      declarations: [WorkflowitemActionsComponent],
      providers: [
        { provide: Injector, useValue: {} },
        { provide: Router, useValue: new RouterStub() },
github vendure-ecommerce / vendure / packages / admin-ui / src / app / catalog / components / product-variants-editor / product-variants-editor.component.ts View on Github external
return this.modalService
                .dialog({
                    title: _('catalog.confirm-adding-options-delete-default-title'),
                    body: _('catalog.confirm-adding-options-delete-default-body'),
                    buttons: [
                        { type: 'seconday', label: _('common.cancel') },
                        { type: 'danger', label: _('catalog.delete-default-variant'), returnValue: true },
                    ],
                })
                .pipe(
                    mergeMap(res => {
                        return res === true ? of(true) : EMPTY;
                    }),
                );
        } else {
            return of(true);
        }
    }
github DSpace / dspace-angular / src / app / core / data / site-data.service.spec.ts View on Github external
const getRequestEntry$ = (successful:boolean, statusCode:number, statusText:string) => {
    return observableOf({
      response: new RestResponse(successful, statusCode, statusText)
    } as RequestEntry);
  };