Skip to content

Commit

Permalink
fix stream to be of type Observable
Browse files Browse the repository at this point in the history
  • Loading branch information
Toon van Strijp committed May 3, 2020
1 parent c331747 commit dd5a808
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main.ts
Expand Up @@ -990,8 +990,8 @@ function generateService(
requestFn = requestFn.addParameter('metadata?', "Metadata@grpc");
}

// Return observable for interface only configuration and passing returnObservable=true
if (options.returnObservable) {
// Return observable for interface only configuration, passing returnObservable=true and methodDesc.serverStreaming=true
if (options.returnObservable || methodDesc.serverStreaming) {
requestFn = requestFn.returns(responseObservable(typeMap, methodDesc));
} else {
requestFn = requestFn.returns(responsePromise(typeMap, methodDesc));
Expand Down Expand Up @@ -1270,6 +1270,9 @@ function generateDataLoadersType(): InterfaceSpec {
}

function requestType(typeMap: TypeMap, methodDesc: MethodDescriptorProto): TypeName {
if(methodDesc.clientStreaming) {
return TypeNames.anyType("Observable@rxjs").param(messageToTypeName(typeMap, methodDesc.inputType));
}
return messageToTypeName(typeMap, methodDesc.inputType);
}

Expand Down

0 comments on commit dd5a808

Please sign in to comment.