RxJava delay for each item of list emitted

The simplest way to do this seems to be just using concatMap and wrapping each item in a delayed Obserable. long startTime = System.currentTimeMillis(); Observable.range(1, 5) .concatMap(i-> Observable.just(i).delay(50, TimeUnit.MILLISECONDS)) .doOnNext(i-> System.out.println( “Item: ” + i + “, Time: ” + (System.currentTimeMillis() – startTime) +”ms”)) .toCompletable().await(); Prints: Item: 1, Time: 51ms Item: 2, Time: 101ms Item: … Read more

Adding delay between execution of two following lines

You can use gcd to do this without having to create another method // ObjC NSTimeInterval delayInSeconds = 2.0; dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ NSLog(@”Do some work”); }); // Swift DispatchQueue.main.asyncAfter(deadline: .now() + 2) { print(“Do some work) } You should still ask yourself “do I really need to add … Read more

How can I delay a :hover effect in CSS?

You can use transitions to delay the :hover effect you want, if the effect is CSS-based. For example div{ transition: 0s background-color; } div:hover{ background-color:red; transition-delay:1s; } this will delay applying the the hover effects (background-color in this case) for one second. Demo of delay on both hover on and off: div{ display:inline-block; padding:5px; margin:10px; … Read more

How to reduce iOS AVPlayer start delay

For iOS 10.x and greater to reduce AVPlayer start delay I set: avplayer.automaticallyWaitsToMinimizeStalling = false; and that seemed to fix it for me. This could have other consequences, but I haven’t hit those yet. I got the idea for it from: https://stackoverflow.com/a/50598525/9620547

How to put a delay on AngularJS instant search?

UPDATE Now it’s easier than ever (Angular 1.3), just add a debounce option on the model. <input type=”text” ng-model=”searchStr” ng-model-options=”{debounce: 1000}”> Updated plunker: http://plnkr.co/edit/4V13gK Documentation on ngModelOptions: https://docs.angularjs.org/api/ng/directive/ngModelOptions Old method: Here’s another method with no dependencies beyond angular itself. You need set a timeout and compare your current string with the past version, if both … Read more

Delaying function in swift [duplicate]

You can use GCD (in the example with a 10 second delay): Swift 2 let triggerTime = (Int64(NSEC_PER_SEC) * 10) dispatch_after(dispatch_time(DISPATCH_TIME_NOW, triggerTime), dispatch_get_main_queue(), { () -> Void in self.functionToCall() }) Swift 3 and Swift 4 DispatchQueue.main.asyncAfter(deadline: .now() + 10.0, execute: { self.functionToCall() }) Swift 5 or Later DispatchQueue.main.asyncAfter(deadline: .now() + 10.0) { //call any function … Read more

How to add a delay for a 2 or 3 seconds [closed]

You could use Thread.Sleep() function, e.g. int milliseconds = 2000; Thread.Sleep(milliseconds); that completely stops the execution of the current thread for 2 seconds. Probably the most appropriate scenario for Thread.Sleep is when you want to delay the operations in another thread, different from the main e.g. : MAIN THREAD ———————————————————> (UI, CONSOLE ETC.) | | … Read more

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