Skip to content
Snippets Groups Projects
Commit 29f55d56 authored by Jorge Canizales's avatar Jorge Canizales
Browse files

Remove GRXWriter wrappers that are now unnecessary

With GRXWriter a subclass of all writers, we can map the requestsWriter directly
without a dumb wrapper, and return GRXImmediateWriter objects where GRXWriter is
expected.
parent a38baaec
No related branches found
No related tags found
No related merge requests found
......@@ -35,7 +35,6 @@
#import <GPBProtocolBuffers.h>
#import <RxLibrary/GRXWriteable.h>
#import <RxLibrary/GRXForwardingWriter.h>
#import <RxLibrary/GRXWriter+Transformations.h>
@implementation ProtoRPC {
......@@ -65,12 +64,11 @@
format:@"A protobuf class to parse the responses must be provided."];
}
// A writer that serializes the proto messages to send.
id<GRXWriter> bytesWriter =
[[[GRXForwardingWriter alloc] initWithWriter:requestsWriter] map:^id(GPBMessage *proto) {
// TODO(jcanizales): Fail with an understandable error message if the requestsWriter isn't
// sending GPBMessages.
return [proto data];
}];
GRXWriter *bytesWriter = [requestsWriter map:^id(GPBMessage *proto) {
// TODO(jcanizales): Fail with an understandable error message if the requestsWriter isn't
// sending GPBMessages.
return [proto data];
}];
if ((self = [super initWithHost:host path:method.HTTPPath requestsWriter:bytesWriter])) {
// A writeable that parses the proto messages received.
_responseWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
......
......@@ -38,27 +38,27 @@
@implementation GRXWriter (Immediate)
+ (instancetype)writerWithEnumerator:(NSEnumerator *)enumerator {
return [[self alloc] initWithWriter:[GRXImmediateWriter writerWithEnumerator:enumerator]];
return [GRXImmediateWriter writerWithEnumerator:enumerator];
}
+ (instancetype)writerWithValueSupplier:(id (^)())block {
return [[self alloc] initWithWriter:[GRXImmediateWriter writerWithValueSupplier:block]];
return [GRXImmediateWriter writerWithValueSupplier:block];
}
+ (instancetype)writerWithContainer:(id<NSFastEnumeration>)container {
return [[self alloc] initWithWriter:[GRXImmediateWriter writerWithContainer:container]];
return [GRXImmediateWriter writerWithContainer:container];
}
+ (instancetype)writerWithValue:(id)value {
return [[self alloc] initWithWriter:[GRXImmediateWriter writerWithValue:value]];
return [GRXImmediateWriter writerWithValue:value];
}
+ (instancetype)writerWithError:(NSError *)error {
return [[self alloc] initWithWriter:[GRXImmediateWriter writerWithError:error]];
return [GRXImmediateWriter writerWithError:error];
}
+ (instancetype)emptyWriter {
return [[self alloc] initWithWriter:[GRXImmediateWriter emptyWriter]];
return [GRXImmediateWriter emptyWriter];
}
@end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment