You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-ios/Signal/src/util/ObservableValue.h

43 lines
1.1 KiB
C

11 years ago
#import <Foundation/Foundation.h>
#import "CollapsingFutures.h"
11 years ago
#import "Queue.h"
typedef void (^LatestValueCallback)(id latestValue);
/**
*
* An ObservableValue represents an asynchronous stream of values, such as 'latest state of toggle' or 'latest sensor
* reading'.
11 years ago
*
*/
@interface ObservableValue : NSObject {
@protected
NSMutableSet *callbacks;
@private
Queue *queuedActionsToRun;
@private
bool isRunningActions;
@protected
bool sealed;
11 years ago
}
@property (readonly, atomic) id currentValue;
11 years ago
- (void)watchLatestValueOnArbitraryThread:(LatestValueCallback)callback
untilCancelled:(TOCCancelToken *)untilCancelledToken;
11 years ago
- (void)watchLatestValue:(LatestValueCallback)callback
onThread:(NSThread *)thread
untilCancelled:(TOCCancelToken *)untilCancelledToken;
11 years ago
@end
@interface ObservableValueController : ObservableValue
+ (ObservableValueController *)observableValueControllerWithInitialValue:(id)value;
- (void)updateValue:(id)value;
- (void)adjustValue:(id (^)(id))adjustment;
- (void)sealValue;
11 years ago
@end