Reputation: 21
Possible to somehow limit the update download 0.3 seconds using a ReactiveCocoa? example:
if (the_previous_update == indefinitely)
{
update;
}
if else (current_time - the_previous_update>=0.3)
{
the_previous_update = current_time;
update;
}
else{
do nothing;
}
Upvotes: 0
Views: 96
Reputation: 3063
Yes as @Grav says a throttle seems like the best operation for your use case. A throttle will basically store up next events and dispatch the last one received within your given time interval.
With a throttle you can make sure that you can update your UI every 0.3 seconds and be sure that the value that you use to update will be the last one received in that given time interval.
This differs from delay.
Upvotes: 0
Reputation: 1714
Maybe something like this?
RACSignal *updateSignal = ... // a signal that sends a 'next' whenever download has progressed.
[[updateSignal throttle:0.3] subscribeNext:^(id x) {
updateUI();
}];
Upvotes: 4