RxJS 6 – Cancel / End a Pipe

You can also cancel/end a pipe by using a signal Subject and the rxjs operator: takeUntil Example httpGetSafe(path: string): Observable<Data> { const stopSignal$ = new Subject(); return this.http.get<Data>(path).pipe( map(data => { const isBad = data === null; if (isBad) { stopSignal$.next(); } return data; }), takeUntil(stopSignal$) ); } Sometimes it’s a bit simpler and more … Read more

tap() vs subscribe() to set a class property

Edit: Ignore this answer! Here is a good answer: https://stackoverflow.com/a/50882183/5932590 See JMD’s comment below for more context! Good question. In the source code for the tap operator, this comment pretty much sums it up: This operator is useful for debugging your Observables for the correct values or performing other side effects. Note: this is different … Read more

UIPicker detect tap on currently selected row

First, conform the class to the UIGestureRecognizerDelegate protocol Then, in the view setup: UITapGestureRecognizer *tapToSelect = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tappedToSelectRow:)]; tapToSelect.delegate = self; [self.pickerView addGestureRecognizer:tapToSelect]; And elsewhere: #pragma mark – Actions – (IBAction)tappedToSelectRow:(UITapGestureRecognizer *)tapRecognizer { if (tapRecognizer.state == UIGestureRecognizerStateEnded) { CGFloat rowHeight = [self.pickerView rowSizeForComponent:0].height; CGRect selectedRowFrame = CGRectInset(self.pickerView.bounds, 0.0, (CGRectGetHeight(self.pickerView.frame) – rowHeight) / 2.0 ); … Read more

Why doesn’t await on Task.WhenAll throw an AggregateException?

I know this is a question that’s already answered but the chosen answer doesn’t really solve the OP’s problem, so I thought I would post this. This solution gives you the aggregate exception (i.e. all the exceptions that were thrown by the various tasks) and doesn’t block (workflow is still asynchronous). async Task Main() { … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)