//
//  UITableViewHeaderFooterView+YSRACSignalSupport.m
//  ReactiveObjC
//
//  Created by Syo Ikeda on 12/30/13.
//  Copyright (c) 2013 GitHub, Inc. All rights reserved.
//

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

@implementation UITableViewHeaderFooterView (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
