mirror of https://github.com/oxen-io/session-ios
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.
38 lines
1.0 KiB
C
38 lines
1.0 KiB
C
11 years ago
|
#import <Foundation/Foundation.h>
|
||
11 years ago
|
#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'.
|
||
|
*
|
||
|
*/
|
||
|
@interface ObservableValue : NSObject {
|
||
|
@protected NSMutableSet* callbacks;
|
||
|
@private Queue* queuedActionsToRun;
|
||
|
@private bool isRunningActions;
|
||
|
@protected bool sealed;
|
||
|
}
|
||
|
|
||
|
@property (readonly,atomic) id currentValue;
|
||
|
|
||
|
-(void) watchLatestValueOnArbitraryThread:(LatestValueCallback)callback
|
||
11 years ago
|
untilCancelled:(TOCCancelToken*)untilCancelledToken;
|
||
11 years ago
|
|
||
|
-(void) watchLatestValue:(LatestValueCallback)callback
|
||
|
onThread:(NSThread*)thread
|
||
11 years ago
|
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;
|
||
|
|
||
|
@end
|