//
//  UITableViewCell+YSRACSignalSupport.m
//  ReactiveObjC
//
//  Created by Justin Spahr-Summers on 2013-07-22.
//  Copyright (c) 2013 GitHub, Inc. All rights reserved.
//

#import "UITableViewCell+YSRACSignalSupport.h"
#import "NSObject+YSRACDescription.h"
#import "NSObject+YSRACSelectorSignal.h"
#import "YSRACSignal+Operations.h"
#import "YSRACUnit.h"
#import <objc/runtime.h>

@implementation UITableViewCell (YSRACSignalSupport)

- (YSRACSignal *)ysrac_prepareForReuseSignal {
	YSRACSignal *signal = objc_getAssociatedObject(self, _cmd);
	if (signal != nil) return signal;

	signal = [[[self
		ysrac_signalForSelector:@selector(prepareForReuse)]
		mapReplace:YSRACUnit.defaultUnit]
		setNameWithFormat:@"%@ -ysrac_prepareForReuseSignal", YSRACDescription(self)];
	
	objc_setAssociatedObject(self, _cmd, signal, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
	return signal;
}

@end
