How to use the fbjs/lib/nullthrows function in fbjs

To help you get started, we’ve selected a few fbjs 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-tck / src / RSocketTckClient.js View on Github external
socket.requestResponse({data, metadata}).subscribe(subscriber);
            } else if (type === 'rs') {
              subscriber = new RSocketTckRequestStreamSubscriber(log);
              socket.requestStream({data, metadata}).subscribe(subscriber);
            } else {
              assert(false, 'Invalid `subscribe` type %s.', type);
            }
            break;
          }
          case 'request': {
            const [n] = args;
            nullthrows(subscriber).request(parseInt(n, 10));
            break;
          }
          case 'cancel': {
            nullthrows(subscriber).cancel();
            break;
          }
          case 'await': {
            const [type, _, nOrTime] = args; // eslint-disable-line no-unused-vars
            if (type === 'terminal') {
              await nullthrows(subscriber).awaitTerminal();
            } else if (type === 'atLeast') {
              await nullthrows(subscriber).awaitN(parseInt(nOrTime, 10));
            } else if (type === 'no_events') {
              await delay(parseInt(nOrTime, 10));
            } else {
              assert(false, 'Invalid `await` type %s.', type);
            }
            break;
          }
          case 'take': {
github rsocket / rsocket-js / packages / rsocket-tck / src / RSocketTckClient.js View on Github external
case 'subscribe': {
            const [type, _, data, metadata] = args; // eslint-disable-line no-unused-vars
            if (type === 'rr') {
              subscriber = new RSocketTckRequestResponseSubscriber(log);
              socket.requestResponse({data, metadata}).subscribe(subscriber);
            } else if (type === 'rs') {
              subscriber = new RSocketTckRequestStreamSubscriber(log);
              socket.requestStream({data, metadata}).subscribe(subscriber);
            } else {
              assert(false, 'Invalid `subscribe` type %s.', type);
            }
            break;
          }
          case 'request': {
            const [n] = args;
            nullthrows(subscriber).request(parseInt(n, 10));
            break;
          }
          case 'cancel': {
            nullthrows(subscriber).cancel();
            break;
          }
          case 'await': {
            const [type, _, nOrTime] = args; // eslint-disable-line no-unused-vars
            if (type === 'terminal') {
              await nullthrows(subscriber).awaitTerminal();
            } else if (type === 'atLeast') {
              await nullthrows(subscriber).awaitN(parseInt(nOrTime, 10));
            } else if (type === 'no_events') {
              await delay(parseInt(nOrTime, 10));
            } else {
              assert(false, 'Invalid `await` type %s.', type);
github rsocket / rsocket-js / packages / rsocket-tck / src / RSocketTckClient.js View on Github external
} else {
              assert(false, 'Invalid `await` type %s.', type);
            }
            break;
          }
          case 'take': {
            const [n] = args;
            await nullthrows(subscriber).awaitN(parseInt(n, 10));
            nullthrows(subscriber).cancel();
            break;
          }
          case 'assert': {
            const [type, _, other] = args; // eslint-disable-line no-unused-vars
            if (type === 'no_error') {
              assert(
                !nullthrows(subscriber).hasError(),
                'Expected onError not to be called.',
              );
            } else if (type === 'error') {
              assert(
                nullthrows(subscriber).hasError(),
                'Expected onError to be called.',
              );
            } else if (type === 'received') {
              const expected = parsePayloads(other);
              const actual = nullthrows(subscriber).getPayloads();
              if (!areEqual(actual, expected)) {
                log('expected: %s', util.inspect(expected));
                log('actual: %s', util.inspect(actual));
                assert(false, 'Actual/expected payloads differed.');
              }
            } else if (type === 'received_n') {
github rsocket / rsocket-js / packages / rsocket-tck / src / RSocketTckClient.js View on Github external
case 'await': {
            const [type, _, nOrTime] = args; // eslint-disable-line no-unused-vars
            if (type === 'terminal') {
              await nullthrows(subscriber).awaitTerminal();
            } else if (type === 'atLeast') {
              await nullthrows(subscriber).awaitN(parseInt(nOrTime, 10));
            } else if (type === 'no_events') {
              await delay(parseInt(nOrTime, 10));
            } else {
              assert(false, 'Invalid `await` type %s.', type);
            }
            break;
          }
          case 'take': {
            const [n] = args;
            await nullthrows(subscriber).awaitN(parseInt(n, 10));
            nullthrows(subscriber).cancel();
            break;
          }
          case 'assert': {
            const [type, _, other] = args; // eslint-disable-line no-unused-vars
            if (type === 'no_error') {
              assert(
                !nullthrows(subscriber).hasError(),
                'Expected onError not to be called.',
              );
            } else if (type === 'error') {
              assert(
                nullthrows(subscriber).hasError(),
                'Expected onError to be called.',
              );
            } else if (type === 'received') {
github rsocket / rsocket-js / packages / rsocket-flowable / src / FlowableTakeOperator.js View on Github external
_cancelAndComplete(): void {
    nullthrows(this._subscription).cancel();
    this._subscriber.onComplete();
  }
}
github iyegoroff / react-native-text-gradient / src / create-text-gradient-class.js View on Github external
onResponderRelease: (event) => {
          nullthrows(this.touchableHandleResponderRelease)(event);
          if (this.props.onResponderRelease != null) {
            this.props.onResponderRelease.call(this, event);
          }
        },
        onResponderTerminate: (event) => {
github rsocket / rsocket-js / packages / rsocket-tck / src / RSocketTckRequestResponseSubscriber.js View on Github external
cancel(): void {
    this._cancelled = true;
    nullthrows(this._subscription).cancel();
  }
github rsocket / rsocket-js / packages / rsocket-tck / src / RSocketTckRequestStreamSubscriber.js View on Github external
cancel(): void {
    this._cancelled = true;
    nullthrows(this._subscription).cancel();
  }