Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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': {
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);
} 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') {
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') {
_cancelAndComplete(): void {
nullthrows(this._subscription).cancel();
this._subscriber.onComplete();
}
}
onResponderRelease: (event) => {
nullthrows(this.touchableHandleResponderRelease)(event);
if (this.props.onResponderRelease != null) {
this.props.onResponderRelease.call(this, event);
}
},
onResponderTerminate: (event) => {
cancel(): void {
this._cancelled = true;
nullthrows(this._subscription).cancel();
}
cancel(): void {
this._cancelled = true;
nullthrows(this._subscription).cancel();
}