<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kalaivani on Medium]]></title>
        <description><![CDATA[Stories by Kalaivani on Medium]]></description>
        <link>https://medium.com/@kalaivani30?source=rss-eba919267b43------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*bV4g-olcTZOmzXSPPEfSFw.jpeg</url>
            <title>Stories by Kalaivani on Medium</title>
            <link>https://medium.com/@kalaivani30?source=rss-eba919267b43------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 19:48:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kalaivani30/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Debounce before Combine era]]></title>
            <link>https://medium.com/@kalaivani30/debounce-before-combine-era-7717685b19d?source=rss-eba919267b43------2</link>
            <guid isPermaLink="false">https://medium.com/p/7717685b19d</guid>
            <category><![CDATA[debounce]]></category>
            <category><![CDATA[uitextfield]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[combine]]></category>
            <dc:creator><![CDATA[Kalaivani]]></dc:creator>
            <pubDate>Thu, 11 Nov 2021 09:46:22 GMT</pubDate>
            <atom:updated>2021-11-12T04:47:05.963Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JZndnhxoD3AMD9TdsOvG0w.png" /></figure><p>When performing network requests while user types in textfield, it is costly to call API for every typed word/letter. This may result in time out as well.</p><p>This is pretty quick and easy using combine framework. If not, then we can simulate debounce using timer and introducing delays. Debounce is like introducing throttle to prevent more network requests from firing , allowing one request per time. This prevents sending too many requests to the backend.</p><p>Debounce acts as a timer by waiting for a specified amount of time and then fires the network request. Meanwhile, if there is another request made in the waiting time period then timer is reset.</p><p>Let’s dive into implementation of Debounce</p><p>Debouncer class has an initializer which configures the timer with delay value and the call back to be called after a delay.</p><p>Debouncer also has a method that can be called to reset the timer and an objC method is linked with the scheduled timer to call after a delay. From this objC method, the call back would be called to perform network requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZL8RrtgPUY_jDQvq3-lkIw.png" /></figure><p>In a view controller class, instantiate Debouncer in the viewDidLoad method with a specified delay and a call back to get fired from Debouncer class. When the text field value is set, Debouncer’s call method to reset timer is called. In the callback, you can perform network requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*0b-2H9ms2TOeA0l4nkLAGg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*QYoG7W1g0duNzud0646bQg.png" /></figure><p>For more details, check out <a href="https://daddycoding.com/2020/03/10/ios-tutorial-debounce-your-network-call/">this</a> link</p><h3>cancelPreviousPerformRequests(withTarget:)</h3><p>There is another alternative way of introducing Debounce using Apple’s native framework. It cancels perform requests previously registered with the <a href="https://developer.apple.com/documentation/objectivec/nsobject/1416176-perform"><strong>perform(_:with:afterDelay:)</strong></a> instance method.</p><p><strong>cancelPreviousPerformRequests(withTarget aTarget: Any)</strong></p><p>All perform requests having the same target aTarget are canceled. This method removes perform requests only in the current run loop, not all run loops.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7717685b19d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tuples in Swift]]></title>
            <link>https://medium.com/@kalaivani30/tuples-in-swift-fdcb3d605ed1?source=rss-eba919267b43------2</link>
            <guid isPermaLink="false">https://medium.com/p/fdcb3d605ed1</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[tuples]]></category>
            <dc:creator><![CDATA[Kalaivani]]></dc:creator>
            <pubDate>Tue, 20 Aug 2019 07:48:09 GMT</pubDate>
            <atom:updated>2021-11-11T00:32:10.536Z</atom:updated>
            <content:encoded><![CDATA[<p>Sometimes our function designed to return <strong>multiple items</strong>.One of the ways is returning an instance of a class directly, caller of the function now have access to all properties of an instance.</p><p>Another way is returning a dictionary with keys and values matching to the number of items we like to return from a function</p><p>But in swift, we have an alternative. That’s called <strong>Tuples</strong>. Swift 4 introduced this type and it is fairly simple to use.</p><p><strong>Tuples</strong></p><p>Tuples are used to store and group multiple values into a single <strong>compound</strong> value.</p><p>Creating Tuple with single value like below:</p><p>let myValue = (2.5)</p><p>Compiler interprets not this as a tuple but as a value inside a tuple.Since this tuple contains a double value, compiler considers myValue as a Double instead of a Tuple containing Double value.</p><p>If we are creating a tuple with more than one value, there is no condition like all the values must be of same type.</p><p>It’s valid to have a tuple like (String,Bool),(Int,float,String)</p><p><strong>We can also have a tuple as a value of other tuple as well.</strong></p><p>let tuple_ex=(“swift”,12,(“Red”,”Blue”,30.4))</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fdcb3d605ed1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>