no message

This commit is contained in:
Peter 2015-06-13 17:20:53 +03:00
parent 270bf0278d
commit 2bf7e85910
6 changed files with 43 additions and 10 deletions

View File

@ -63,6 +63,7 @@ static dispatch_block_t recursiveBlock(void (^block)(dispatch_block_t recurse))
if ([currentShouldRestart boolValue])
{
[currentDisposable setDisposable:nil];
id<SDisposable> disposable = [self startWithNext:^(id next)
{
[subscriber putNext:next];

View File

@ -172,13 +172,13 @@
- (SSignal *)then:(SSignal *)signal
{
return [[SSignal alloc] initWithGenerator:^(SSubscriber *subscriber)
{
SDisposableSet *compositeDisposable = [[SDisposableSet alloc] init];
SMetaDisposable *currentDisposable = [[SMetaDisposable alloc] init];
[compositeDisposable add:currentDisposable];
return [[SSignal alloc] initWithGenerator:^(SSubscriber *subscriber)
{
[currentDisposable setDisposable:[self startWithNext:^(id next)
{
[subscriber putNext:next];

View File

@ -2,6 +2,7 @@
@interface SSignal (SideEffects)
- (SSignal *)onStart:(void (^)())f;
- (SSignal *)onNext:(void (^)(id next))f;
- (SSignal *)afterNext:(void (^)(id next))f;
- (SSignal *)onError:(void (^)(id error))f;

View File

@ -5,6 +5,24 @@
@implementation SSignal (SideEffects)
- (SSignal *)onStart:(void (^)())f
{
return [[SSignal alloc] initWithGenerator:^id<SDisposable> (SSubscriber *subscriber)
{
f();
return [self startWithNext:^(id next)
{
[subscriber putNext:next];
} error:^(id error)
{
[subscriber putError:error];
} completed:^
{
[subscriber putCompletion];
}];
}];
}
- (SSignal *)onNext:(void (^)(id next))f
{
return [[SSignal alloc] initWithGenerator:^id<SDisposable> (SSubscriber *subscriber)

View File

@ -86,6 +86,8 @@
#ifdef DEBUG
return [[SSignal alloc] initWithGenerator:^id<SDisposable>(SSubscriber *subscriber)
{
NSString *traceName = [[NSString alloc] initWithFormat:@"%@#0x%x", name, (int)random()];
NSLog(@"trace(%@ start)", traceName);
return [self startWithNext:^(id next)
{
[subscriber putNext:next];
@ -95,7 +97,7 @@
} completed:^
{
[subscriber putCompletion];
} traceName:name];
} traceName:traceName];
}];
#else
return self;

View File

@ -150,6 +150,11 @@
OSSpinLockLock(&_lock);
if (!_terminated)
{
NSLog(@"trace(%@ terminated)", _name);
if ([_name hasPrefix:@"bestTcp4Signals"])
{
int bp = 1;
}
_terminated = true;
_next = nil;
_error = nil;
@ -169,9 +174,11 @@
if (fnext)
{
NSLog(@"(%@ next: %@)", _name, next);
NSLog(@"trace(%@ next: %@)", _name, next);
fnext(next);
}
else
NSLog(@"trace(%@ next: %@, not accepted)", _name, next);
}
- (void)putError:(id)error
@ -193,9 +200,11 @@
if (ferror)
{
NSLog(@"(%@ error: %@)", _name, error);
NSLog(@"trace(%@ error: %@)", _name, error);
ferror(error);
}
else
NSLog(@"trace(%@ error: %@, not accepted)", _name, error);
if (shouldDispose)
[self->_disposable dispose];
@ -220,9 +229,11 @@
if (completed)
{
NSLog(@"(%@ completed)", _name);
NSLog(@"trace(%@ completed)", _name);
completed();
}
else
NSLog(@"trace(%@ completed, not accepted)", _name);
if (shouldDispose)
[self->_disposable dispose];
@ -230,7 +241,7 @@
- (void)dispose
{
NSLog(@"(%@ dispose)", _name);
NSLog(@"trace(%@ dispose)", _name);
[self->_disposable dispose];
}