mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-07 08:01:10 +00:00
no message
This commit is contained in:
parent
270bf0278d
commit
2bf7e85910
@ -63,6 +63,7 @@ static dispatch_block_t recursiveBlock(void (^block)(dispatch_block_t recurse))
|
|||||||
|
|
||||||
if ([currentShouldRestart boolValue])
|
if ([currentShouldRestart boolValue])
|
||||||
{
|
{
|
||||||
|
[currentDisposable setDisposable:nil];
|
||||||
id<SDisposable> disposable = [self startWithNext:^(id next)
|
id<SDisposable> disposable = [self startWithNext:^(id next)
|
||||||
{
|
{
|
||||||
[subscriber putNext:next];
|
[subscriber putNext:next];
|
||||||
|
@ -172,13 +172,13 @@
|
|||||||
|
|
||||||
- (SSignal *)then:(SSignal *)signal
|
- (SSignal *)then:(SSignal *)signal
|
||||||
{
|
{
|
||||||
SDisposableSet *compositeDisposable = [[SDisposableSet alloc] init];
|
|
||||||
|
|
||||||
SMetaDisposable *currentDisposable = [[SMetaDisposable alloc] init];
|
|
||||||
[compositeDisposable add:currentDisposable];
|
|
||||||
|
|
||||||
return [[SSignal alloc] initWithGenerator:^(SSubscriber *subscriber)
|
return [[SSignal alloc] initWithGenerator:^(SSubscriber *subscriber)
|
||||||
{
|
{
|
||||||
|
SDisposableSet *compositeDisposable = [[SDisposableSet alloc] init];
|
||||||
|
|
||||||
|
SMetaDisposable *currentDisposable = [[SMetaDisposable alloc] init];
|
||||||
|
[compositeDisposable add:currentDisposable];
|
||||||
|
|
||||||
[currentDisposable setDisposable:[self startWithNext:^(id next)
|
[currentDisposable setDisposable:[self startWithNext:^(id next)
|
||||||
{
|
{
|
||||||
[subscriber putNext:next];
|
[subscriber putNext:next];
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
@interface SSignal (SideEffects)
|
@interface SSignal (SideEffects)
|
||||||
|
|
||||||
|
- (SSignal *)onStart:(void (^)())f;
|
||||||
- (SSignal *)onNext:(void (^)(id next))f;
|
- (SSignal *)onNext:(void (^)(id next))f;
|
||||||
- (SSignal *)afterNext:(void (^)(id next))f;
|
- (SSignal *)afterNext:(void (^)(id next))f;
|
||||||
- (SSignal *)onError:(void (^)(id error))f;
|
- (SSignal *)onError:(void (^)(id error))f;
|
||||||
|
@ -5,6 +5,24 @@
|
|||||||
|
|
||||||
@implementation SSignal (SideEffects)
|
@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
|
- (SSignal *)onNext:(void (^)(id next))f
|
||||||
{
|
{
|
||||||
return [[SSignal alloc] initWithGenerator:^id<SDisposable> (SSubscriber *subscriber)
|
return [[SSignal alloc] initWithGenerator:^id<SDisposable> (SSubscriber *subscriber)
|
||||||
|
@ -86,6 +86,8 @@
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
return [[SSignal alloc] initWithGenerator:^id<SDisposable>(SSubscriber *subscriber)
|
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)
|
return [self startWithNext:^(id next)
|
||||||
{
|
{
|
||||||
[subscriber putNext:next];
|
[subscriber putNext:next];
|
||||||
@ -95,7 +97,7 @@
|
|||||||
} completed:^
|
} completed:^
|
||||||
{
|
{
|
||||||
[subscriber putCompletion];
|
[subscriber putCompletion];
|
||||||
} traceName:name];
|
} traceName:traceName];
|
||||||
}];
|
}];
|
||||||
#else
|
#else
|
||||||
return self;
|
return self;
|
||||||
|
@ -150,6 +150,11 @@
|
|||||||
OSSpinLockLock(&_lock);
|
OSSpinLockLock(&_lock);
|
||||||
if (!_terminated)
|
if (!_terminated)
|
||||||
{
|
{
|
||||||
|
NSLog(@"trace(%@ terminated)", _name);
|
||||||
|
if ([_name hasPrefix:@"bestTcp4Signals"])
|
||||||
|
{
|
||||||
|
int bp = 1;
|
||||||
|
}
|
||||||
_terminated = true;
|
_terminated = true;
|
||||||
_next = nil;
|
_next = nil;
|
||||||
_error = nil;
|
_error = nil;
|
||||||
@ -169,9 +174,11 @@
|
|||||||
|
|
||||||
if (fnext)
|
if (fnext)
|
||||||
{
|
{
|
||||||
NSLog(@"(%@ next: %@)", _name, next);
|
NSLog(@"trace(%@ next: %@)", _name, next);
|
||||||
fnext(next);
|
fnext(next);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
NSLog(@"trace(%@ next: %@, not accepted)", _name, next);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)putError:(id)error
|
- (void)putError:(id)error
|
||||||
@ -193,9 +200,11 @@
|
|||||||
|
|
||||||
if (ferror)
|
if (ferror)
|
||||||
{
|
{
|
||||||
NSLog(@"(%@ error: %@)", _name, error);
|
NSLog(@"trace(%@ error: %@)", _name, error);
|
||||||
ferror(error);
|
ferror(error);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
NSLog(@"trace(%@ error: %@, not accepted)", _name, error);
|
||||||
|
|
||||||
if (shouldDispose)
|
if (shouldDispose)
|
||||||
[self->_disposable dispose];
|
[self->_disposable dispose];
|
||||||
@ -220,9 +229,11 @@
|
|||||||
|
|
||||||
if (completed)
|
if (completed)
|
||||||
{
|
{
|
||||||
NSLog(@"(%@ completed)", _name);
|
NSLog(@"trace(%@ completed)", _name);
|
||||||
completed();
|
completed();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
NSLog(@"trace(%@ completed, not accepted)", _name);
|
||||||
|
|
||||||
if (shouldDispose)
|
if (shouldDispose)
|
||||||
[self->_disposable dispose];
|
[self->_disposable dispose];
|
||||||
@ -230,7 +241,7 @@
|
|||||||
|
|
||||||
- (void)dispose
|
- (void)dispose
|
||||||
{
|
{
|
||||||
NSLog(@"(%@ dispose)", _name);
|
NSLog(@"trace(%@ dispose)", _name);
|
||||||
[self->_disposable dispose];
|
[self->_disposable dispose];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user