How to use the rsocket-flowable.Flowable function in rsocket-flowable

To help you get started, we’ve selected a few rsocket-flowable 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 rsocket / rsocket-js / packages / rsocket-websocket-server / src / RSocketWebSocketServer.js View on Github external
connectionStatus(): Flowable {
    return new Flowable(subscriber => {
      subscriber.onSubscribe({
        cancel: () => {
          this._statusSubscribers.delete(subscriber);
        },
        request: () => {
          this._statusSubscribers.add(subscriber);
          subscriber.onNext(this._status);
        },
      });
    });
  }
github rsocket / rsocket-js / packages / rsocket-core / src / RSocketResumableTransport.js View on Github external
receive(): Flowable {
    return new Flowable(subject => {
      let added = false;
      subject.onSubscribe({
        cancel: () => {
          this._receivers.delete(subject);
        },
        request: () => {
          if (!added) {
            added = true;
            this._receivers.add(subject);
          }
        },
      });
    });
  }
github netifi / spring-demo / browser-ranking / src / main / js / proto / service_rsocket_pb.js View on Github external
RecordsServiceServer.prototype.requestStream = function requestStream(payload) {
    try {
      if (payload.metadata == null) {
        return rsocket_flowable.Flowable.error(new Error('metadata is empty'));
      }
      var method = rsocket_rpc_frames.getMethod(payload.metadata);
      var spanContext = rsocket_rpc_tracing.deserializeTraceData(this._tracer, payload.metadata);
      switch (method) {
        case 'records':
          return this.recordsMetrics(
            this.recordsTrace(spanContext)(new rsocket_flowable.Flowable(subscriber => {
              var binary = !payload.data || payload.data.constructor === Buffer || payload.data.constructor === Uint8Array ? payload.data : new Uint8Array(payload.data);
              return this._service
                .records(service_pb.RecordsRequest.deserializeBinary(binary), payload.metadata)
                .map(function (message) {
                  return {
                    data: Buffer.from(message.serializeBinary()),
                    metadata: Buffer.alloc(0)
                  }
                }).subscribe(subscriber);
              }
            )
          )
        );
        default:
          return rsocket_flowable.Flowable.error(new Error('unknown method'));
      }
github facebook / flipper / src / utils / js-client / serverUtils.tsx View on Github external
connectionStatus(): Flowable {
    return new Flowable(subscriber => {
      subscriber.onSubscribe({
        cancel: () => {
          this.connStatusSubscribers.delete(subscriber);
        },
        request: _ => {
          this.connStatusSubscribers.add(subscriber);
          subscriber.onNext(this.connStatus);
        },
      });
    });
  }
github rsocket / rsocket-js / packages / rsocket-core / src / RSocketMachine.js View on Github external
requestStream(payload: Payload): Flowable> {
    const leaseError = this._useLeaseOrError(this._requesterLeaseHandler);
    if (leaseError) {
      return Flowable.error(new Error(leaseError));
    }

    const streamId = this._getNextStreamId(this._receivers);

    return new Flowable(
      subscriber => {
        this._receivers.set(streamId, subscriber);
        let initialized = false;

        subscriber.onSubscribe({
          cancel: () => {
            this._receivers.delete(streamId);
            if (!initialized) {
              return;
            }
            const cancelFrame = {
              flags: 0,
              streamId,
              type: FRAME_TYPES.CANCEL,
            };
            this._connection.sendOne(cancelFrame);
github rsocket / rsocket-js / packages / rsocket-websocket-server / src / RSocketWebSocketServer.js View on Github external
start(): Flowable {
    return new Flowable(subscriber => {
      let server: ws.Server;
      const onClose = () => {
        if (server) {
          server.stop();
        }
        subscriber.onComplete();
      };
      const onError = error => subscriber.onError(error);
      const onConnection = socket => {
        subscriber.onNext(new WSDuplexConnection(socket, this._encoders));
      };
      subscriber.onSubscribe({
        cancel: () => {
          if (!server) {
            return;
          }
github rsocket / rsocket-js / packages / rsocket-tcp-client / src / RSocketTcpClient.js View on Github external
receive(): Flowable {
    return new Flowable(subject => {
      subject.onSubscribe({
        cancel: () => {
          this._receivers.delete(subject);
        },
        request: () => {
          this._receivers.add(subject);
        },
      });
    });
  }
github rsocket / rsocket-rpc-js / rsocket-rpc-js / packages / core / src / SwitchTransformOperator.js View on Github external
map(fn: (data: T) => R): IPublisher {
    return new Flowable(subscriber => this.subscribe(subscriber)).map(fn);
  }
}
github rsocket / rsocket-rpc-js / rsocket-rpc-js / packages / ipc / src / IPCRSocketService.js View on Github external
requestChannel(payloads: Flowable>) {
    return new Flowable(subscriber => payloads.subscribe(subscriber))
    .lift(sub => 
      new SwitchTransformOperator(
        sub,
        (firstPayload, restOfPayloads) => {
          const method: string = this._getMethod(firstPayload);
          const spanContext = deserializeTraceData(
            this._tracer,
            firstPayload.metadata,
          );
          const unmarshalledData = restOfPayloads
            .map(this._marshaller.unmarshall)
            .map(payload => payload.data);
          return this._getMetricsWrapper(true, method)(
            this._getTracingWrapper(true, method)(spanContext)(
              this._handler[method](
                unmarshalledData,
github rsocket / rsocket-js / packages / rsocket-core / src / RSocketMachine.js View on Github external
_handleRequestChannel(streamId: number, frame: RequestChannelFrame): void {
    const existingSubscription = this._subscriptions.get(streamId);
    if (existingSubscription) {
      //Likely a duplicate REQUEST_CHANNEL frame, ignore per spec
      return;
    }

    const payloads = new Flowable(
      subscriber => {
        let firstRequest = true;

        subscriber.onSubscribe({
          cancel: () => {
            this._receivers.delete(streamId);
            const cancelFrame = {
              flags: 0,
              streamId,
              type: FRAME_TYPES.CANCEL,
            };
            this._connection.sendOne(cancelFrame);
          },
          request: n => {
            if (n > MAX_REQUEST_N) {
              n = MAX_REQUEST_N;