Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Turn <RCLSignal> into a category on RACSignal instead #18

Merged
merged 3 commits into from
Dec 20, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Demos/DeviceRotation/DeviceRotation/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ @interface ViewController () {
}

// Sends the new interface orientation every time a rotation occurs.
@property (nonatomic, strong, readonly) id<RACSignal> rotationSignal;
@property (nonatomic, strong, readonly) RACSignal *rotationSignal;

@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UITextView *nameTextView;
Expand All @@ -39,7 +39,7 @@ - (void)viewDidLoad {

self.view.backgroundColor = UIColor.lightGrayColor;

id<RCLSignal> insetBounds = [self.view.rcl_boundsSignal insetWidth:[RACSignal return:@16] height:[RACSignal return:@16]];
RACSignal *insetBounds = [self.view.rcl_boundsSignal insetWidth:[RACSignal return:@16] height:[RACSignal return:@16]];

self.nameLabel = [[UILabel alloc] initWithFrame:CGRectZero];
[self.view addSubview:self.nameLabel];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ - (void)windowDidLoad {
NSTextField *nameLabel = [self labelWithString:NSLocalizedString(@"Name", @"")];
NSTextField *emailLabel = [self labelWithString:NSLocalizedString(@"Email Address", @"")];

id<RACSignal> labelWidth = [RACSignal max:@[ nameLabel.rcl_boundsSignal.size.width, emailLabel.rcl_boundsSignal.size.width ]];
RACSignal *labelWidth = [RACSignal max:@[ nameLabel.rcl_boundsSignal.size.width, emailLabel.rcl_boundsSignal.size.width ]];

NSTextField *nameField = [self textFieldWithString:@""];
NSTextField *emailField = [self textFieldWithString:@""];

RACTupleUnpack(id<RCLSignal> nameRect, id<RCLSignal> emailRect) = [[self.contentView.rcl_frameSignal
RACTupleUnpack(RACSignal *nameRect, RACSignal *emailRect) = [[self.contentView.rcl_frameSignal
insetWidth:[RACSignal return:@32] height:[RACSignal return:@16]]
divideWithAmount:nameField.rcl_boundsSignal.size.height padding:[RACSignal return:@8] fromEdge:CGRectMaxYEdge];

Expand Down
2 changes: 1 addition & 1 deletion External/ReactiveCocoa
48 changes: 16 additions & 32 deletions ReactiveCocoaLayout.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions ReactiveCocoaLayout/NSView+RCLObservationAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import <Cocoa/Cocoa.h>

@protocol RCLSignal;
@class RCLSignal;

@interface NSView (RCLObservationAdditions)

Expand All @@ -18,14 +18,14 @@
// changes are received.
//
// Returns a signal which sends the current and all future values for `bounds`.
- (id<RCLSignal>)rcl_boundsSignal;
- (RACSignal *)rcl_boundsSignal;

// Observes the receiver's `frame` for changes.
//
// This method may enable `postsFrameChangedNotifications` to ensure that
// changes are received.
//
// Returns a signal which sends the current and all future values for `frame`.
- (id<RCLSignal>)rcl_frameSignal;
- (RACSignal *)rcl_frameSignal;

@end
4 changes: 2 additions & 2 deletions ReactiveCocoaLayout/NSView+RCLObservationAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@implementation NSView (RCLObservationAdditions)

- (id)rcl_boundsSignal {
- (RACSignal *)rcl_boundsSignal {
// TODO: This only needs to be enabled when we actually start watching for
// the notification (i.e., after the startWith:).
self.postsBoundsChangedNotifications = YES;
Expand All @@ -23,7 +23,7 @@ - (id)rcl_boundsSignal {
startWith:[NSValue valueWithRect:self.bounds]];
}

- (id)rcl_frameSignal {
- (RACSignal *)rcl_frameSignal {
// TODO: This only needs to be enabled when we actually start watching for
// the notification (i.e., after the startWith:).
self.postsFrameChangedNotifications = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,71 +1,65 @@
//
// RCLSignal.h
// RACSignal+RCLGeometryAdditions.h
// ReactiveCocoaLayout
//
// Created by Justin Spahr-Summers on 2012-12-12.
// Copyright (c) 2012 GitHub. All rights reserved.
//

#import "EXTConcreteProtocol.h"
#import <ReactiveCocoa/ReactiveCocoa.h>

// A concrete protocol representing a geometric signal.
//
// When conforming to this protocol in a custom class, only `@required` methods
// need to be implemented. Default implementations will automatically be
// provided for any methods marked as `@concrete`. For more information, see
// EXTConcreteProtocol.h.
@protocol RCLSignal <RACSignal>
@concrete
// Adds geometry functions to RACSignal.
@interface RACSignal (RCLGeometryAdditions)

// Constructs rects from the given X, Y, width, and height signals.
//
// Returns a signal of CGRect values.
+ (id<RCLSignal>)rectsWithX:(id<RACSignal>)xSignal Y:(id<RACSignal>)ySignal width:(id<RACSignal>)widthSignal height:(id<RACSignal>)heightSignal;
+ (RACSignal *)rectsWithX:(RACSignal *)xSignal Y:(RACSignal *)ySignal width:(RACSignal *)widthSignal height:(RACSignal *)heightSignal;

// Constructs rects from the given origin and size signals.
//
// Returns a signal of CGRect values.
+ (id<RCLSignal>)rectsWithOrigin:(id<RACSignal>)originSignal size:(id<RACSignal>)sizeSignal;
+ (RACSignal *)rectsWithOrigin:(RACSignal *)originSignal size:(RACSignal *)sizeSignal;

// Maps CGRect values to their `size` fields.
//
// Returns a signal of CGSize values.
- (id<RCLSignal>)size;
- (RACSignal *)size;

// Constructs sizes from the given width and height signals.
//
// Returns a signal of CGSize values.
+ (id<RCLSignal>)sizesWithWidth:(id<RACSignal>)widthSignal height:(id<RACSignal>)heightSignal;
+ (RACSignal *)sizesWithWidth:(RACSignal *)widthSignal height:(RACSignal *)heightSignal;

// Maps CGSize values to their `width` fields.
//
// Returns a signal of CGFloat values.
- (id<RCLSignal>)width;
- (RACSignal *)width;

// Maps CGSize values to their `height` fields.
//
// Returns a signal of CGFloat values.
- (id<RCLSignal>)height;
- (RACSignal *)height;

// Maps CGRect values to their `origin` fields.
//
// Returns a signal of CGPoint values.
- (id<RCLSignal>)origin;
- (RACSignal *)origin;

// Constructs points from the given X and Y signals.
//
// Returns a signal of CGPoint values.
+ (id<RCLSignal>)pointsWithX:(id<RACSignal>)xSignal Y:(id<RACSignal>)ySignal;
+ (RACSignal *)pointsWithX:(RACSignal *)xSignal Y:(RACSignal *)ySignal;

// Maps CGPoint values to their `x` fields.
//
// Returns a signal of CGFloat values.
- (id<RCLSignal>)x;
- (RACSignal *)x;

// Maps CGPoint values to their `y` fields.
//
// Returns a signal of CGFloat values.
- (id<RCLSignal>)y;
- (RACSignal *)y;

// Insets each CGRect by the number of points sent from the given width and
// height signals.
Expand All @@ -76,7 +70,7 @@
// to remove from both the top and bottom sides of the rectangle.
//
// Returns a signal of new, inset CGRect values.
- (id<RCLSignal>)insetWidth:(id<RACSignal>)widthSignal height:(id<RACSignal>)heightSignal;
- (RACSignal *)insetWidth:(RACSignal *)widthSignal height:(RACSignal *)heightSignal;

// Trims each CGRect to the number of points sent from `amountSignal`, as
// measured starting from the given edge.
Expand All @@ -87,7 +81,7 @@
// edge - The edge from which to start including points in the slice.
//
// Returns a signal of CGRect slices.
- (id<RCLSignal>)sliceWithAmount:(id<RACSignal>)amountSignal fromEdge:(CGRectEdge)edge;
- (RACSignal *)sliceWithAmount:(RACSignal *)amountSignal fromEdge:(CGRectEdge)edge;

// From the given edge of each CGRect, trims the number of points sent from
// `amountSignal`.
Expand All @@ -98,10 +92,10 @@
// edge - The edge from which to trim.
//
// Returns a signal of CGRect remainders.
- (id<RCLSignal>)remainderAfterSlicingAmount:(id<RACSignal>)amountSignal fromEdge:(CGRectEdge)edge;
- (RACSignal *)remainderAfterSlicingAmount:(RACSignal *)amountSignal fromEdge:(CGRectEdge)edge;

// Invokes -divideWithAmount:padding:fromEdge: with a constant padding of 0.
- (RACTuple *)divideWithAmount:(id<RACSignal>)sliceAmountSignal fromEdge:(CGRectEdge)edge;
- (RACTuple *)divideWithAmount:(RACSignal *)sliceAmountSignal fromEdge:(CGRectEdge)edge;

// Divides each CGRect into two component rectangles, skipping an amount of
// padding between them.
Expand All @@ -121,7 +115,7 @@
//
// Returns a RACTuple containing two signals, which will send the slices and
// remainders, respectively.
- (RACTuple *)divideWithAmount:(id<RACSignal>)sliceAmountSignal padding:(id<RACSignal>)paddingSignal fromEdge:(CGRectEdge)edge;
- (RACTuple *)divideWithAmount:(RACSignal *)sliceAmountSignal padding:(RACSignal *)paddingSignal fromEdge:(CGRectEdge)edge;

// Sends the maximum value sent by any of the given signals.
//
Expand All @@ -130,7 +124,7 @@
// will send the new maximum.
//
// Returns a signal which sends NSNumber maximum values.
+ (id<RCLSignal>)max:(NSArray *)signals;
+ (RACSignal *)max:(NSArray *)signals;

// Sends the minimum value sent by any of the given signals.
//
Expand All @@ -139,6 +133,6 @@
// will send the new minimum.
//
// Returns a signal which sends NSNumber minimum values.
+ (id<RCLSignal>)min:(NSArray *)signals;
+ (RACSignal *)min:(NSArray *)signals;

@end
Loading