Merge pull request #2903 from jcanizales/shorten-names

Rename SingleValueHandler->SingleHandler, StreamHandler->EventHandler
pull/2631/merge
Michael Lumish 9 years ago
commit 6933745d25
  1. 4
      src/compiler/objective_c_generator.cc
  2. 8
      src/objective-c/RxLibrary/GRXWriteable.h
  3. 4
      src/objective-c/RxLibrary/GRXWriteable.m
  4. 14
      src/objective-c/tests/RxLibraryUnitTests.m

@ -154,9 +154,9 @@ void PrintAdvancedImplementation(Printer *printer,
printer->Print(" responsesWriteable:[GRXWriteable "); printer->Print(" responsesWriteable:[GRXWriteable ");
if (method->server_streaming()) { if (method->server_streaming()) {
printer->Print("writeableWithStreamHandler:eventHandler]];\n"); printer->Print("writeableWithEventHandler:eventHandler]];\n");
} else { } else {
printer->Print("writeableWithSingleValueHandler:handler]];\n"); printer->Print("writeableWithSingleHandler:handler]];\n");
} }
printer->Print("}\n"); printer->Print("}\n");

@ -48,15 +48,15 @@
typedef void (^GRXValueHandler)(id value); typedef void (^GRXValueHandler)(id value);
typedef void (^GRXCompletionHandler)(NSError *errorOrNil); typedef void (^GRXCompletionHandler)(NSError *errorOrNil);
typedef void (^GRXSingleValueHandler)(id value, NSError *errorOrNil); typedef void (^GRXSingleHandler)(id value, NSError *errorOrNil);
typedef void (^GRXStreamHandler)(BOOL done, id value, NSError *error); typedef void (^GRXEventHandler)(BOOL done, id value, NSError *error);
// Utility to create objects that conform to the GRXWriteable protocol, from // Utility to create objects that conform to the GRXWriteable protocol, from
// blocks that handle each of the two methods of the protocol. // blocks that handle each of the two methods of the protocol.
@interface GRXWriteable : NSObject<GRXWriteable> @interface GRXWriteable : NSObject<GRXWriteable>
+ (instancetype)writeableWithSingleValueHandler:(GRXSingleValueHandler)handler; + (instancetype)writeableWithSingleHandler:(GRXSingleHandler)handler;
+ (instancetype)writeableWithStreamHandler:(GRXStreamHandler)handler; + (instancetype)writeableWithEventHandler:(GRXEventHandler)handler;
- (instancetype)initWithValueHandler:(GRXValueHandler)valueHandler - (instancetype)initWithValueHandler:(GRXValueHandler)valueHandler
completionHandler:(GRXCompletionHandler)completionHandler completionHandler:(GRXCompletionHandler)completionHandler

@ -38,7 +38,7 @@
GRXCompletionHandler _completionHandler; GRXCompletionHandler _completionHandler;
} }
+ (instancetype)writeableWithSingleValueHandler:(GRXSingleValueHandler)handler { + (instancetype)writeableWithSingleHandler:(GRXSingleHandler)handler {
if (!handler) { if (!handler) {
return [[self alloc] init]; return [[self alloc] init];
} }
@ -51,7 +51,7 @@
}]; }];
} }
+ (instancetype)writeableWithStreamHandler:(GRXStreamHandler)handler { + (instancetype)writeableWithEventHandler:(GRXEventHandler)handler {
if (!handler) { if (!handler) {
return [[self alloc] init]; return [[self alloc] init];
} }

@ -55,7 +55,7 @@
return [[self alloc] init]; return [[self alloc] init];
} }
- (GRXSingleValueHandler)block { - (GRXSingleHandler)block {
return ^(id value, NSError *errorOrNil) { return ^(id value, NSError *errorOrNil) {
++_timesCalled; ++_timesCalled;
_value = value; _value = value;
@ -71,13 +71,13 @@
#pragma mark Writeable #pragma mark Writeable
- (void)testWriteableSingleValueHandlerIsCalledForValue { - (void)testWriteableSingleHandlerIsCalledForValue {
// Given: // Given:
CapturingSingleValueHandler *handler = [CapturingSingleValueHandler handler]; CapturingSingleValueHandler *handler = [CapturingSingleValueHandler handler];
id anyValue = @7; id anyValue = @7;
// If: // If:
id<GRXWriteable> writeable = [GRXWriteable writeableWithSingleValueHandler:handler.block]; id<GRXWriteable> writeable = [GRXWriteable writeableWithSingleHandler:handler.block];
[writeable writeValue:anyValue]; [writeable writeValue:anyValue];
// Then: // Then:
@ -86,13 +86,13 @@
XCTAssertEqualObjects(handler.errorOrNil, nil); XCTAssertEqualObjects(handler.errorOrNil, nil);
} }
- (void)testWriteableSingleValueHandlerIsCalledForError { - (void)testWriteableSingleHandlerIsCalledForError {
// Given: // Given:
CapturingSingleValueHandler *handler = [CapturingSingleValueHandler handler]; CapturingSingleValueHandler *handler = [CapturingSingleValueHandler handler];
NSError *anyError = [NSError errorWithDomain:@"domain" code:7 userInfo:nil]; NSError *anyError = [NSError errorWithDomain:@"domain" code:7 userInfo:nil];
// If: // If:
id<GRXWriteable> writeable = [GRXWriteable writeableWithSingleValueHandler:handler.block]; id<GRXWriteable> writeable = [GRXWriteable writeableWithSingleHandler:handler.block];
[writeable writesFinishedWithError:anyError]; [writeable writesFinishedWithError:anyError];
// Then: // Then:
@ -106,7 +106,7 @@
- (void)testBufferedPipePropagatesValue { - (void)testBufferedPipePropagatesValue {
// Given: // Given:
CapturingSingleValueHandler *handler = [CapturingSingleValueHandler handler]; CapturingSingleValueHandler *handler = [CapturingSingleValueHandler handler];
id<GRXWriteable> writeable = [GRXWriteable writeableWithSingleValueHandler:handler.block]; id<GRXWriteable> writeable = [GRXWriteable writeableWithSingleHandler:handler.block];
id anyValue = @7; id anyValue = @7;
// If: // If:
@ -123,7 +123,7 @@
- (void)testBufferedPipePropagatesError { - (void)testBufferedPipePropagatesError {
// Given: // Given:
CapturingSingleValueHandler *handler = [CapturingSingleValueHandler handler]; CapturingSingleValueHandler *handler = [CapturingSingleValueHandler handler];
id<GRXWriteable> writeable = [GRXWriteable writeableWithSingleValueHandler:handler.block]; id<GRXWriteable> writeable = [GRXWriteable writeableWithSingleHandler:handler.block];
NSError *anyError = [NSError errorWithDomain:@"domain" code:7 userInfo:nil]; NSError *anyError = [NSError errorWithDomain:@"domain" code:7 userInfo:nil];
// If: // If:

Loading…
Cancel
Save