Comments (4)
You only need to call the error's subscribeNext:
once. It sounds like you're calling it multiple times. Can you share some code?
from reactiveobjc.
sure; the view like below picture;
if the server send error like 403(cause my app don't be verified so the server limit the interface call times). And the user can did this sendBtn
more times, so the errors
subscribeBlock can be executed more times, as same as the command
be executed more times too; Here is my code, so can i have some solution to avoid this kind of problem?
[[_sendBtn rac_signalForControlEvents:UIControlEventTouchDown] subscribeNext:^(id x) {
[weakSelf.sendViewModel.sendCommand.executionSignals.switchToLatest subscribeNext:^(id x) {
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeText;
hud.labelText = @"已发送";
[hud hide:YES afterDelay:1.0];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.view endEditing:YES];
[self dismissViewControllerAnimated:YES completion:nil];
});
}];
[weakSelf.sendViewModel.sendCommand.errors subscribeNext:^(id x) {
LJLog(@"()()()()"); // click more times the text will be loged more times
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeText;
hud.labelText = @"新浪服务器开小差了...";
[hud hide:YES afterDelay:1.0];
}];
NSDictionary *dict = @{@"statusd":_textView.text};
[self.sendViewModel.sendCommand execute:dict];
}];
from reactiveobjc.
You shouldn't subscribe to errors
or executionSignals
every time the button is pressed. It should only happen once.
[weakSelf.sendViewModel.sendCommand.executionSignals.switchToLatest subscribeNext:^(id x) {
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeText;
hud.labelText = @"已发送";
[hud hide:YES afterDelay:1.0];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.view endEditing:YES];
[self dismissViewControllerAnimated:YES completion:nil];
});
}];
[weakSelf.sendViewModel.sendCommand.errors subscribeNext:^(id x) {
LJLog(@"()()()()"); // click more times the text will be loged more times
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeText;
hud.labelText = @"新浪服务器开小差了...";
[hud hide:YES afterDelay:1.0];
}];
[[_sendBtn rac_signalForControlEvents:UIControlEventTouchDown] subscribeNext:^(id x) {
NSDictionary *dict = @{@"statusd":_textView.text};
[self.sendViewModel.sendCommand execute:dict];
}];
from reactiveobjc.
ok, thank you very much.
from reactiveobjc.
Related Issues (20)
- RACObserve(target, key) HOT 1
- should I check the existance of weakself before @strongify(self) ? HOT 3
- [RACCommand addActiveExecutionSignal:]crashed HOT 2
- Error: 'ReactiveObjC/EXTKeyPathCoding.h' file not found?
- why the instruments say that the RAC Memory leaks?
- Why use pods package tools make static frame error ? .podspec is ok? HOT 1
- OSAtomic deprecation in iOS 10.0 HOT 1
- Xcode12 ReactiveObjC archive error HOT 2
- SMP HAVE NO SUPPORT
- 3.1.1 endless loop
- AVPlayerItem was deallocated while key value observers were still registered with it.
- crash in -[NSObject(RACDeallocating) rac_deallocDisposable] NSObject+RACDeallocating.m
- Delay delays cancelled stream completion
- 闪退 HOT 1
- m1 Can't install 3.1.1 via CocoaPods
- ReactiveObjC (3.1.1) Build Failed
- Get build errors with Xcode 15 HOT 3
- Xcode 15 Release build error "error: unexpected '@' in program @weakify(self); ^" HOT 2
- iOS 17 Crash
- Apple requires third-party SDKs to contain a privacy manifest file HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reactiveobjc.