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

To help you get started, we’ve selected a few @reactivex/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 giltig / rxfrf / src / shared / stores / counterStore.js View on Github external
export const count =
  Observable
    .merge(increase, decrease)
    .scan(add)
    .startWith(0)

/* ========================== handlers ====================================== */

export const increaseCount =
  Observable.of(() => {
    dispatch(Actions.COUNTER_INCREASED)
  })

export const decreaseCount =
  Observable.of(() => {
    dispatch(Actions.COUNTER_DECREASED)
  })

/* ======================== all together ==================================== */

export default
  Observable
    .combineLatestObj({count, increaseCount, decreaseCount})
github machinelabs / machinelabs / server / src / messaging.service.ts View on Github external
.switchMap(validationContext => {
                                if (validationContext.isApproved()) {
                                  // if we get the approval, create the meta data
                                  this.createExecutionAndUpdateLabs(invocation, hash);
                                  // and execute the code
                                  return this.codeRunner
                                            .run(invocation, validationContext.labConfiguration)
                                            .map(data => this.processStreamDataToExecutionMessage(data))
                                            .startWith({
                                              kind: MessageKind.ExecutionStarted,
                                              data: 'Execution started... (this might take a little while)'
                                            })
                                            .concat(Observable.of({
                                              kind: MessageKind.ExecutionFinished,
                                              data: ''
                                            }))
                                            .do(msg => {
                                              if (msg.kind === MessageKind.ExecutionFinished){
                                                this.completeExecution(invocation);
                                              }
                                            })
                                }

                                // if we don't get an approval, reject it
                                return Observable.of({
                                  kind: MessageKind.ExecutionRejected,
                                  data: validationContext.approval.message
                                });
                              });
github giltig / rxfrf / src / shared / stores / counterStore.js View on Github external
.mapTo(1)

const decrease =
  getPayload(Actions.COUNTER_DECREASED)
    .mapTo(-1)

export const count =
  Observable
    .merge(increase, decrease)
    .scan(add)
    .startWith(0)

/* ========================== handlers ====================================== */

export const increaseCount =
  Observable.of(() => {
    dispatch(Actions.COUNTER_INCREASED)
  })

export const decreaseCount =
  Observable.of(() => {
    dispatch(Actions.COUNTER_DECREASED)
  })

/* ======================== all together ==================================== */

export default
  Observable
    .combineLatestObj({count, increaseCount, decreaseCount})
github kitten / fluorine / test / dispatcher / schedule.js View on Github external
test('accepts observables to schedule an agenda', t => {
  const dispatcher = createDispatcher()

  const addThree = Observable
    .interval(200)
    .take(3)
    .map(() => add)

  dispatcher.schedule(addThree)
  dispatcher.schedule(Observable.of(subtract), Observable.of(subtract))

  dispatcher
    .reduce(AdderStore)
    .bufferCount(6)
    .subscribe(x => {
      t.same(x, [ 0, 1, 2, 3, 2, 1 ])
    }, err => {
      t.fail()
    }, () => {
      t.end()
    })
})
github kitten / fluorine / test / util / isObservable.js View on Github external
test(t => {
  t.ok(isObservable(Observable.of('Value')))

  t.notOk(isObservable())
  t.notOk(isObservable({}))
  t.notOk(isObservable(() => {}))
})
github machinelabs / machinelabs / server / src / lab-config / lab-config.service.ts View on Github external
toInternalConfig(userId: string, publicConfig: PublicLabConfiguration) {
    let config = new InternalLabConfiguration();

    if (!publicConfig) {
      config.errors.push('Could not parse file');
      return Observable.of(config);
    }

    config.inputs = publicConfig.inputs;
    config.parameters = publicConfig.parameters;
    config.imageWithDigest = this.dockerImageService.getImageNameWithDigest(publicConfig.dockerImageId);

    return this.mountService.validateMounts(userId, publicConfig.mounts)
    .do(validated => config.errors.push(...validated.errors))
    .do(validated => config.mountPoints = validated.mountPoints)
    .map(_ => config)
    .map(this.reportError('Invalid parameters', this.hasValidParameters))
    .map(this.reportError('Unknown dockerImageId', this.isValidImage))
    .map(this.reportError('Invalid inputs', this.hasValidInputs));
  }
github machinelabs / machinelabs / server / src / rules.service.ts View on Github external
.switchMap(user => {
                    let approval = !user || user.isAnonymous ? this.rejectAnonymous(invocation) : this.allow(invocation);
                    return Observable.of(approval);
                  });
  }
github sourcegraph / javascript-typescript-langserver / src / typescript-service.ts View on Github external
shutdown(params = {}, span = new Span()): Observable {
		this.projectManager.dispose();
		this.packageManager.dispose();
		return Observable.of({ op: 'add', path: '', value: null } as AddPatch);
	}
github sourcegraph / javascript-typescript-langserver / src / typescript-service.ts View on Github external
xworkspaceReferencesProvider: true,
				xdefinitionProvider: true,
				xdependenciesProvider: true,
				completionProvider: {
					resolveProvider: false,
					triggerCharacters: ['.']
				},
				codeActionProvider: true,
				renameProvider: true,
				executeCommandProvider: {
					commands: []
				},
				xpackagesProvider: true
			}
		};
		return Observable.of({
			op: 'add',
			path: '',
			value: result
		} as OpPatch);
	}