<?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 Nilaakash Singh on Medium]]></title>
        <description><![CDATA[Stories by Nilaakash Singh on Medium]]></description>
        <link>https://medium.com/@nilaakash?source=rss-746d5a78d859------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gH0aAi4mp4Hsqb4OI9rKCw.png</url>
            <title>Stories by Nilaakash Singh on Medium</title>
            <link>https://medium.com/@nilaakash?source=rss-746d5a78d859------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 08:12:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nilaakash/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[The Evolution of the Software Developer: The Rise of System-Level Engineering]]></title>
            <link>https://blog.devgenius.io/the-evolution-of-the-software-developer-the-rise-of-system-level-engineering-d6142c217fa5?source=rss-746d5a78d859------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6142c217fa5</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[future-of-work]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Nilaakash Singh]]></dc:creator>
            <pubDate>Sun, 22 Mar 2026 03:49:38 GMT</pubDate>
            <atom:updated>2026-03-24T01:04:14.331Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>SOFTWARE FACTORY SERIES · ARTICLE 1 OF 9</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*40Q9Fdv0vFCr4Fta2Da-Vw.jpeg" /></figure><p>The industry is buzzing with fear that AI is coming for our keyboards. If your only value is translating logic into raw syntax, that fear is justified. But look at how real, enterprise-grade software is actually built, and a much more exciting reality emerges: AI isn’t replacing developers — it’s promoting them.</p><p>We are entering the era of the “Software Factory.” However, there is a dangerous myth circulating that this factory is run by a single “10x Developer” whispering prompts into an omnipotent AI. Enterprise software doesn’t work like that. If your system crashes during Black Friday, a single engineer cannot debug the entire stack, no matter how good their AI is.</p><p>Instead, professional responsibilities are shifting, and the engineering org chart is evolving into a symbiotic structure. Every tier of the engineering team is getting a specialized AI counterpart. We are witnessing the death of the “code monkey” and the rise of the system-level engineer.</p><p>Here is how the new AI-empowered engineering hierarchy actually works when building a massive system — like a modern, omnichannel e-commerce platform powered by standard RESTful architecture.</p><h3>1. The Principal Layer: Topologies and Trade-offs</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*27p22JfyDO8dgfIdIi7ygQ.png" /><figcaption><strong>The Principal Layer.</strong> The conductor with a god’s-eye view.</figcaption></figure><p>At the top of the technical hierarchy, the <strong>Principal Engineer</strong> pairs with a <strong>Principal Agent</strong>. They operate at the 10,000-foot view. They do not write individual database queries or configure local environments; they dictate the global topology and system constraints.</p><p>Imagine the company needs a new progressive web app (PWA) and native iOS/Android apps. The Principal Engineer writes the architectural intent:</p><blockquote>“Principal Agent: Architect an event-driven microservices backend for our new omnichannel shopping platform. We require strict ACID compliance for the checkout service, so provision a PostgreSQL cluster. For the product catalog, provision a geographically distributed NoSQL datastore. Route all client traffic through a centralized API Gateway, and utilize a Backend-for-Frontend (BFF) pattern to serve optimized REST endpoints for the Web, iOS, and Android applications respectively.”</blockquote><p>The AI generates the boilerplate, scaffolds the microservices, and sets up the infrastructure as code. The human makes the high-level, business-critical trade-offs — choosing consistency for payments and high availability for the catalog. The AI handles the execution.</p><p>But here is what the prompt doesn’t show: before that instruction was written, the Principal Engineer spent two weeks negotiating with the VP of Product about why a single monolith wouldn’t scale, mediating between the iOS and Android teams about API versioning strategy, and aligning the CTO on a CapEx vs. OpEx decision for cloud provisioning. That context — political, organizational, financial — is the invisible architecture no AI can generate.</p><h3>2. The Staff Layer: Domains and Translation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Abm2R5rStcFLJIhhRjHpxg.png" /></figure><p>One level down, <strong>Staff Engineers</strong> partner with <strong>Domain Agents</strong> to own specific bounded contexts. But the Staff Engineer’s role is far more nuanced than simply pointing an AI at a technical problem. They operate at the intersection of people, systems, and time — and that intersection is where the real complexity lives.</p><h3>The Human Side of Domain Ownership</h3><p>Staff Engineers are the organizational diplomats of the engineering hierarchy. They are the ones who attend the quarterly business review and translate “we need faster inventory updates” into a set of precise technical constraints. They own the relationships with the warehouse ops team, the finance system vendors, and the platform architects above them. AI cannot negotiate a data-sharing agreement. AI cannot de-escalate the tension when the legacy SOAP API team refuses to expose a new field because it will “break their SLAs.” That is Staff Engineer territory.</p><p>Consider the challenge of bridging your pristine new microservices with a 15-year-old on-premises SOAP API that manages warehouse inventory. The Staff Engineer doesn’t just hand this problem to an agent and walk away. They first spend days in workshops with the warehouse team, cataloguing which legacy XML fields are still actively populated, which ones haven’t been touched since 2009, and which ones mean entirely different things depending on the regional warehouse. That institutional knowledge becomes the blueprint the agent works from.</p><h3>The AI Side: Execution Without Exhaustion</h3><p>Once the Staff Engineer has mapped the domain and defined the constraints, they direct their Domain Agent to build the translation layer:</p><blockquote>“Inventory Agent: Read the legacy XML SOAP responses, map the inventory counts to our modern RESTful JSON schema, and expose it via an internal microservice. Implement circuit breakers — if the legacy system takes more than 2 seconds to respond, fail open and return a 206 Partial Content HTTP status with a ‘Low Stock’ warning rather than hanging the user’s checkout process.”</blockquote><p>The<strong> Staff Engineer</strong> acts as the <strong>diplomat</strong> defining the failover strategy and HTTP semantics; the AI acts as the translator writing the tedious mapping logic. What would have taken a developer two weeks of reading undocumented WSDL files and writing boilerplate Java transformers is now scaffolded in hours.</p><h3>Cross-Domain Coordination: Where Staff Engineers Truly Shine</h3><p>The most underappreciated aspect of the Staff layer is cross-domain coordination — and it is precisely where the “single omnipotent AI” myth collapses. When the Inventory Domain Agent and the Checkout Domain Agent produce services that need to communicate, somebody has to define the contract between them. That somebody is the Staff Engineer.</p><p>They facilitate the API contract review between the two domain teams, enforce consistency in error schema conventions across services, and make the call when the checkout team wants synchronous inventory confirmation but the warehouse team can only guarantee eventual consistency. These are not technical questions with objectively correct answers. They are judgment calls with long-term consequences, made by engineers who understand the full blast radius of each decision.</p><p>In this sense, Staff Engineers in the Software Factory become something closer to system architects than senior developers. Their pairing with a Domain Agent doesn’t diminish their role — it amplifies it, freeing them from the implementation grind and forcing their focus upward, to the decisions that actually define system quality.</p><h3>3. The Developer Layer: Execution and Ground Truth</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j3ZMDxsx5WcHGHcBktfMHA.png" /><figcaption><strong>The Developer Layer.</strong> 3am. On fire. Only one person can fix this.</figcaption></figure><p>The role of the mid-level developer doesn’t disappear; it becomes hyper-focused on systemic quality, support, and deep technical execution. <strong>Developers</strong> pair with <strong>Task Agents</strong> to become the ground-level domain experts.</p><p>Why is this human layer more critical than ever? Because AI hallucinates, and AI doesn’t carry a pager.</p><p>When a complex synchronization issue arises — say, the iOS app is throwing <strong>429 Too Many Requests</strong> errors because the mobile BFF is over-fetching data — the developer steps in. When an AI-generated SQL query unexpectedly locks a critical table during peak traffic, a “prompt engineer” cannot fix it. You need a human developer who understands how indexing works, who can read the REST payload logs alongside their AI assistant, and who can surgically intervene.</p><p>Crucially, the Developer layer is also the quality gate for everything the AI above them produces. They are the first humans to actually run the generated code, to notice that the circuit breaker logic the Domain Agent wrote doesn’t account for connection pool exhaustion, and to flag it back up the chain. The Staff Engineer defines what to build; the Developer validates that what was built actually works in the real world.</p><p>The AI generates the code, but human developers must maintain the deep, structural understanding of the system to support it in production.</p><h3>4. The DevOps Layer: CI/CD and Continuous Testing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2dk2Lzb6H19gdrTswhcSQw.png" /><figcaption><strong>DevOps Layer.</strong> The pipeline runs itself. Engineer sleeps.</figcaption></figure><p>Writing robust test suites and maintaining brittle CI/CD YAML files has traditionally been the tax developers pay for deployment. In the Software Factory, this tax is largely eliminated.</p><p>When a Developer completes a new REST endpoint for the shopping cart, they don’t spend the next three hours mocking database connections to write unit tests. Instead, they define the testing parameters:</p><blockquote>“QA Agent, generate edge-case integration tests for the new cart endpoint. Ensure it handles malformed JSON payloads, tests for race conditions during simultaneous checkout clicks, and validates the 409 Conflict status if inventory is depleted during the transaction.”</blockquote><p>Simultaneously, the DevOps Agent manages the pipeline. It catches the pull request, provisions ephemeral testing environments, and runs the entire suite across the Web, iOS, and Android builds. If the deployment causes a latency spike in the mobile BFF, the agent automatically halts the rollout, rolls back to the previous stable state, and flags the bottleneck for review. The human engineer no longer babysits the pipeline; they govern the release strategy.</p><h3>The Quality Leap</h3><p>When we hand over the repetitive friction of syntax, legacy translation, and pipeline management to an agentic hierarchy, something remarkable happens to the software itself: it gets dramatically better.</p><p>Because our mental bandwidth is no longer consumed by chasing missing brackets or debugging broken test configurations, human engineers can focus entirely on what matters: optimizing REST caching strategies, hardening security boundaries, and ensuring the system degrades gracefully under pressure.</p><p>But the most profound shift isn’t technical — it’s organizational. The hierarchy described here only works because each layer of humans retains deep expertise. Principal Engineers who don’t understand distributed systems trade-offs cannot write meaningful architectural intent. Staff Engineers who haven’t earned the trust of their cross-functional partners cannot negotiate the contracts that hold the system together. Developers who don’t understand indexing cannot catch the queries that will collapse under load.</p><p>AI accelerates all of these people. It does not replace any of them. The Software Factory isn’t a machine run by prompts — it’s a team of deeply skilled engineers, each finally freed to do the work they were always supposed to be doing.</p><p>We aren’t writing less software. We are finally building software the way it was always meant to be built — with a relentless focus on the big picture.</p><p><strong>Share this blog to spread the knowledge | Do Follow, and CLAP if you Liked it! Happy Agenting :)</strong></p><p><strong>Add me on </strong><a href="https://www.linkedin.com/in/nilaakash-singh-79a386b2/"><strong>Linkedin</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6142c217fa5" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/the-evolution-of-the-software-developer-the-rise-of-system-level-engineering-d6142c217fa5">The Evolution of the Software Developer: The Rise of System-Level Engineering</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Frozen Structs in Swift: Benefits, Examples, and Performance Comparison]]></title>
            <link>https://nilaakash.medium.com/frozen-structs-in-swift-benefits-examples-and-performance-comparison-9c6b8a4c717d?source=rss-746d5a78d859------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c6b8a4c717d</guid>
            <dc:creator><![CDATA[Nilaakash Singh]]></dc:creator>
            <pubDate>Sun, 04 Feb 2024 01:06:59 GMT</pubDate>
            <atom:updated>2024-02-04T01:06:59.053Z</atom:updated>
            <content:encoded><![CDATA[<p>Swift’s <strong>frozen structs</strong> bring a unique perspective to immutability, offering benefits in terms of predictability, safety, and performance. <br>In this article, we’ll explore the advantages, delve into practical examples using a <strong>Decodable</strong> model, and conduct a performance comparison between non-frozen and frozen structs.<br>Let’s get started:</p><h3>Benefits of Frozen Structs:</h3><h4>1. Immutability for Predictability:</h4><p>Immutability ensures that once an instance is created, its properties remain unchanged, enhancing code predictability.</p><p><strong><em>Example</em></strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/17c892263f804c2d0a41194c88d26d81/href">https://medium.com/media/17c892263f804c2d0a41194c88d26d81/href</a></iframe><h4>2. Safer Concurrency:</h4><p>Immutability simplifies concurrent programming, reducing the risk of data races.</p><p><strong><em>Example:</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/68094b8a6b770d26feb8bf16338c64eb/href">https://medium.com/media/68094b8a6b770d26feb8bf16338c64eb/href</a></iframe><h4>3. Performance Optimizations:</h4><p>The <a href="http://twitter.com/frozen">@frozen</a> attribute allows the compiler to optimize performance, making assumptions about the immutability of the struct.</p><p><strong><em>Example:</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e47614241554e24ae07171db1e56d557/href">https://medium.com/media/e47614241554e24ae07171db1e56d557/href</a></iframe><h4>4. Value Semantics:</h4><p>Frozen structs align with Swift’s value semantics, promoting a functional programming style.</p><p><strong><em>Example:</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb577b7f511501c14c26f61ce119b97d/href">https://medium.com/media/eb577b7f511501c14c26f61ce119b97d/href</a></iframe><h4>Performance Comparison:</h4><p>Let’s compare the performance of non-frozen and frozen structs in a scenario involving frequent modifications.</p><blockquote>Scenario: Modifying an Array</blockquote><h4>Non-frozen Struct:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1711c92f1508dea65546f4635a93c383/href">https://medium.com/media/1711c92f1508dea65546f4635a93c383/href</a></iframe><h4>Frozen Struct:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/715d6e11382b6627f26f10e684946648/href">https://medium.com/media/715d6e11382b6627f26f10e684946648/href</a></iframe><p>In this scenario, the non-frozen struct allows direct modification of the array, potentially leading to more efficient memory usage. However, the frozen struct requires creating a new instance for each modification, introducing a level of indirection.</p><h3>Disadvantages and Considerations:</h3><h4>1. Overhead for Copying:</h4><p>Immutable structures require creating a new instance for each modification, potentially leading to increased memory usage.</p><p><strong><em>Example:</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/12febaa6f4dc3f567fb83ef73852ae78/href">https://medium.com/media/12febaa6f4dc3f567fb83ef73852ae78/href</a></iframe><h4>2. Limited Use Cases:</h4><p>While powerful, frozen structs may not be suitable for scenarios requiring frequent modifications.</p><p><strong><em>Example:</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/12febaa6f4dc3f567fb83ef73852ae78/href">https://medium.com/media/12febaa6f4dc3f567fb83ef73852ae78/href</a></iframe><h4>3. Learning Curve:</h4><p>Developers new to the concept of frozen structs may find the strict immutability rules initially challenging.</p><h4>Using Frozen Structs with Decodable Models:</h4><p>Consider a scenario where immutability is desired for decoding JSON data into a model. Using a frozen struct can provide clarity and safety in this context.</p><p><strong><em>Example:</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9aa479024e99ce7d789850047febce3c/href">https://medium.com/media/9aa479024e99ce7d789850047febce3c/href</a></iframe><h3>Conclusion:</h3><p>Frozen structs in Swift offer a robust approach to immutability, enhancing code predictability and safety. While the performance comparison highlights potential overhead for copying in certain scenarios, careful consideration of your application’s needs will guide you in leveraging the benefits of frozen structs effectively.</p><p><strong>Share this blog to spread the knowledge | Do Follow, and CLAP if you Liked it! Happy Coding :)</strong></p><p><strong>Add me on </strong><a href="https://www.linkedin.com/in/nilaakash-singh-79a386b2/"><strong>Linkedin</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c6b8a4c717d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Combining Operators in Combine Framework]]></title>
            <link>https://blog.devgenius.io/combining-operators-in-combine-framework-37b8ba043a1d?source=rss-746d5a78d859------2</link>
            <guid isPermaLink="false">https://medium.com/p/37b8ba043a1d</guid>
            <category><![CDATA[combine]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Nilaakash Singh]]></dc:creator>
            <pubDate>Sat, 06 Jan 2024 21:34:18 GMT</pubDate>
            <atom:updated>2024-01-08T17:34:26.456Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we will delve into the Combining operators of the Combine Framework in iOS. These operators allow us to combine, interleave, and concatenate data streams, much like how collection and filter operators work on series of data.</p><p><strong>Use Cases:</strong> Combining data streams is a frequent task in programming. The Combine framework provides numerous ways to <strong>merge</strong>, <strong>zip</strong>, <strong>append</strong>, and <strong>prepend</strong> sequences of data. <br>These operations can be chained together, and the combination is applied to each element as it traverses through the operators, rather than performing the operation on sets of data. <br>In this article, we will introduce some of these operators and encourage you to explore the many more that the Combine framework offers.</p><p><strong>Prerequisites:</strong></p><ul><li>Xcode 11 and above which supports Combine framework</li><li>Basic knowledge of Publishers, Subscribers, and Subjects.</li></ul><p>Let’s get started:</p><h3>Prepend and Append:</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c82bb7758a9549a6cbd11247baa6e358/href">https://medium.com/media/c82bb7758a9549a6cbd11247baa6e358/href</a></iframe><p>The above code creates two publishers, numbers and negativeNumbers, which emit sequences of positive and negative numbers respectively. <br>The prepend operator is used to add additional numbers or sequences to the beginning of the numbers sequence. The sink function then subscribes to the final sequence and prints each number as it is received. The end result is a printed sequence of numbers from -5 to 5.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e90179f15d2ea01edf7c4392236ef60c/href">https://medium.com/media/e90179f15d2ea01edf7c4392236ef60c/href</a></iframe><p>The above code creates two publishers, numbers and negativeNumbers, which emit sequences of negative numbers. <br>The append operator is used to add additional numbers or sequences to the end of the numbers sequence. The sink function then subscribes to the final sequence and prints each number as it is received. The end result is a printed sequence of numbers from -5 to 5.</p><h3>Switch to Latest:</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a6041653e1ac71910f050944cf3669c3/href">https://medium.com/media/a6041653e1ac71910f050944cf3669c3/href</a></iframe><p>The above code creates two PassthroughSubject publishers, publisher1 and publisher2, and a third PassthroughSubject, publishers, that emits these publishers. <br>The switchToLatest operator is used to subscribe to the most recent publisher emitted by publishers. The sink function prints each value received. <br>When publishers sends publisher1, its values are printed. However, when publishers sends publisher2, the subscription switches to publisher2 and only its values are printed. Any subsequent values sent by publisher1 are ignored.</p><h3>Merge:</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f840788f3784258949d85e87590b71e4/href">https://medium.com/media/f840788f3784258949d85e87590b71e4/href</a></iframe><p>The above code creates two PassthroughSubject publishers, publisher1 and publisher2. <br>The merge operator is used to combine the outputs of these two publishers into a single stream of values. The sink function subscribes to this merged stream and prints each value received. When publisher1 sends the value 20, it is printed, and when publisher2 sends the value 30,</p><h3>Combine Latest:</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed3e8b8d34a5317bc93e6b9104ee545e/href">https://medium.com/media/ed3e8b8d34a5317bc93e6b9104ee545e/href</a></iframe><p>The above code creates two PassthroughSubject publishers, publisher1 and publisher2, which emit Int and String values respectively. <br>The combineLatest operator is used to combine the latest values from both publishers. The sink function subscribes to this combined stream and prints each pair of values received. When publisher1 sends a number and publisher2 sends a string, both are printed together.</p><h3>Zip:</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/57e3f931d024a5c3d8d43d1b2bc3858b/href">https://medium.com/media/57e3f931d024a5c3d8d43d1b2bc3858b/href</a></iframe><p>The above code creates two PassthroughSubject publishers, publisher1 and publisher2, which emit Int and String values respectively. <br>The zip operator pairs the corresponding values from each publisher together. The sink function subscribes to this combined stream and prints each pair of values received. When publisher1 sends a number and publisher2 sends a string, both are printed together.</p><p>That’s it from Combining Operators in Combine Framework. With this we’ve covered all the operators provided by combine.<br>I’ll be back with more articles in future on other iOS subjects.</p><h3>Where to go from here:</h3><p>We can utilize these combining operators when we are using subscribers to retrieve data from a database or server. This will assist us in merging and coordinating data streams, and in discarding unnecessary data right from the start. These operators can be particularly useful when we need to handle multiple sources of data or when we need to synchronize data updates from different publishers. By understanding and effectively using these combining operators, we can make our data handling code more efficient and easier to understand.<br> You can find the different combined operator and their usage in my <a href="https://github.com/NilaakashSingh/CombineConcepts"><strong>GitHub</strong></a> repository.</p><p><strong>More Reads: <br></strong> <strong>Sequence operators in Combine:</strong> <a href="https://blog.devgenius.io/sequence-operators-in-combine-framework-c942182150a">https://blog.devgenius.io/sequence-operators-in-combine-framework-c942182150a</a></p><p><strong>Filtering Operators in Combine Framework</strong>: <a href="https://medium.com/dev-genius/filtering-operators-in-combine-framework-d51798d4e2a9">https://medium.com/dev-genius/filtering-operators-in-combine-framework-d51798d4e2a9</a></p><p><strong>Transforming Operators in Combine Framework</strong>: <a href="https://medium.com/dev-genius/transforming-map-operators-in-combine-framework-2cdc809195c1">https://medium.com/dev-genius/transforming-map-operators-in-combine-framework-2cdc809195c1</a></p><p><strong>Share this blog to spread the knowledge | Do Follow, and CLAP if you Liked it! Happy Coding :)</strong></p><p><strong>Add me on </strong><a href="https://www.linkedin.com/in/nilaakash-singh-79a386b2/"><strong>Linkedin</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37b8ba043a1d" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/combining-operators-in-combine-framework-37b8ba043a1d">Combining Operators in Combine Framework</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing Dynamic Size Class Changes in SwiftUI: A Guide to Custom Modifiers for iPhone and iPad…]]></title>
            <link>https://medium.com/loblaw-digital/observing-size-class-changes-in-swiftui-with-custom-modifiers-4504409f88ec?source=rss-746d5a78d859------2</link>
            <guid isPermaLink="false">https://medium.com/p/4504409f88ec</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[swiftui]]></category>
            <dc:creator><![CDATA[Nilaakash Singh]]></dc:creator>
            <pubDate>Wed, 03 Jan 2024 18:14:14 GMT</pubDate>
            <atom:updated>2024-03-16T00:36:32.033Z</atom:updated>
            <content:encoded><![CDATA[<h3>Implementing Dynamic Size Class Changes in SwiftUI: A Guide to Custom Modifiers for iPhone and iPad Devices</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zTy3AMpdTCH-wo6R6uwVfQ.png" /></figure><p>In SwiftUI, the environment provides us with size classes that we can use to adapt our user interface to different screen sizes. However, observing changes to these size classes can be a bit challenging. In this article, we’ll create a ViewModifier that observes changes to the size classes and performs an action in response.</p><p>Before we move forward, let’s discuss the benefits of supporting size classes:</p><ol><li><strong>Adaptive Design</strong>: Size classes enable your app to adapt to various device sizes and orientations. This ensures your app maintains a consistent appearance, whether it’s being used on a small iPhone or a large iPad.</li><li><strong>Dynamic and Responsive Layout</strong>: By observing size classes, your app can dynamically adjust its layout based on the current environment, making your app more flexible and user-friendly.</li><li><strong>Improved User Experience</strong>: Adjusting the layout and elements of your app based on the device and orientation can enhance the user experience. For instance, you might display more information on a larger screen or adjust the size of buttons for easier interaction on a smaller screen.</li><li><strong>Efficient Use of Screen Real Estate</strong>: Size classes help you optimize the available screen space. You can prioritize the most crucial information or controls based on the current size class.</li><li><strong>Ease of Maintenance</strong>: Size classes allow you to manage different layouts for various devices and orientations in a centralized manner. This approach simplifies your code maintenance and update process.</li><li><strong>Future-Proofing</strong>: As new devices are introduced, your app will be able to adapt to their screen sizes and orientations without requiring significant changes to your code.</li></ol><p>Let’s get started:</p><h3>Creating the SizeClass Struct</h3><p>First, we need a way to represent the size classes. We’ll create a SizeClass struct that holds the horizontal and vertical size classes:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1fc49869df1723754c6db5ee812ba7e5/href">https://medium.com/media/1fc49869df1723754c6db5ee812ba7e5/href</a></iframe><p>This struct also conforms to Equatable, which allows us to observe changes to it using the onChange modifier.</p><h3>Creating the SizeClassAwareModifier</h3><p>Next, we’ll create a SizeClassAwareModifier that observes changes to the size classes:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c4a42947b910e4bdb2c61855a889b2fa/href">https://medium.com/media/c4a42947b910e4bdb2c61855a889b2fa/href</a></iframe><p>In this ViewModifier, we use the @Environment property wrapper to get the current size classes, and the @Binding property wrapper to update a SizeClass property whenever the size classes change.</p><h3>Using the SizeClassAwareModifier</h3><p>To use the SizeClassAwareModifier, we&#39;ll create an extension on View that applies the modifier:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b6d0d65b7dc5183ac9ad004a71ccae17/href">https://medium.com/media/b6d0d65b7dc5183ac9ad004a71ccae17/href</a></iframe><p>Now we can use the observeSizeClasses(sizeClass:) method in our views to observe changes to the size classes:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c47992425686ceb1119f559703717525/href">https://medium.com/media/c47992425686ceb1119f559703717525/href</a></iframe><p>In this example, the ContentView has a @State property that holds the current size classes. It passes this property to the observeSizeClasses(sizeClass:) method, allowing the SizeClassAwareModifier to update it whenever the size classes change.</p><h3>Conclusion</h3><p>In this article, we’ve seen how to create a ViewModifier that observes changes to the size classes in SwiftUI. This can be a powerful tool for adapting your user interface to different screen sizes. However, remember that SwiftUI provides other tools for adaptive design as well, such as the @Environment(\.horizontalSizeClass) and @Environment(\.verticalSizeClass) property wrappers, and the ViewThatFits coupled with stacks.</p><p><strong>Share this blog to spread the knowledge | Do Follow, and CLAP if you Liked it! Happy Coding :)</strong></p><p><strong>Loblaw Digital</strong> on <a href="https://www.linkedin.com/company/loblaw-digital/">Linkedin</a><strong> | Nilaakash </strong>on <a href="https://www.linkedin.com/in/nilaakash-singh-79a386b2/">Linkedin</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4504409f88ec" width="1" height="1" alt=""><hr><p><a href="https://medium.com/loblaw-digital/observing-size-class-changes-in-swiftui-with-custom-modifiers-4504409f88ec">Implementing Dynamic Size Class Changes in SwiftUI: A Guide to Custom Modifiers for iPhone and iPad…</a> was originally published in <a href="https://medium.com/loblaw-digital">Loblaw Digital</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bappa…]]></title>
            <link>https://nilaakash.medium.com/bappa-769dfe19e677?source=rss-746d5a78d859------2</link>
            <guid isPermaLink="false">https://medium.com/p/769dfe19e677</guid>
            <category><![CDATA[dogs]]></category>
            <dc:creator><![CDATA[Nilaakash Singh]]></dc:creator>
            <pubDate>Mon, 02 Oct 2023 19:42:38 GMT</pubDate>
            <atom:updated>2023-10-02T19:52:34.093Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fXbrZMrDdTyA-0EZfzkoSw.jpeg" /></figure><blockquote>I came to you with nothing but my plea,<br>In innocence, I sought your grace and decree.<br>Your blessings poured, milestones in my name,<br>Emotions surged whenever you left, not the same.</blockquote><blockquote>I was but a fool, yet you shaped my way,<br>Grateful for more than I deserved each day.<br>You witnessed my life’s journey unfold,<br>In your name, my story of strength was told.</blockquote><blockquote>During the year of the pandemic’s reign,<br>I couldn’t visit, but my prayers remained.<br>Watching live feeds and photos from a cage,<br>You stayed by my side, in every life stage.</blockquote><blockquote>I kept believing, and you made me strong,<br>In times of hardship, you proved me wrong.<br>But this year, your absence, a heavy blow,<br>I felt like there was no place left to go.</blockquote><blockquote>Bappa, you reside deep within our heart,<br>A memento I made, a work of art.<br>I’ll cherish it forever, my solemn vow,<br>And pray for all who serve you, here and now.</blockquote><blockquote>Thank you, Bappa, for all you’ve done,<br>Gratitude fills my heart, for every single one.<br>Words may fall short, emotions run deep,<br>In your love and blessings, my soul shall keep.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=769dfe19e677" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cricket……]]></title>
            <link>https://nilaakash.medium.com/cricket-2c18feb8d6a0?source=rss-746d5a78d859------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c18feb8d6a0</guid>
            <category><![CDATA[poetry]]></category>
            <dc:creator><![CDATA[Nilaakash Singh]]></dc:creator>
            <pubDate>Sun, 29 Jan 2023 19:30:28 GMT</pubDate>
            <atom:updated>2023-09-12T16:19:57.880Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Bachpan mein tujhse naata jud gaya,<br>Tabse laga na aur koi apna.<br>Mai toh tehra bhola sa baalak,<br>Bas leke chala ek sapna 🎾🏏</blockquote><blockquote>Jab sath rehta hun,<br>Na dar, baer, bhed bav rakhta hun<br>Aur tujhse dur rahu toh,<br>Kisi aur ke baaremein na sochta hun 🤷🏻‍♂️</blockquote><blockquote>Mere hum umar saathi,<br>Chale vilayat duniya jitne<br>Mai toh tehra vairagi,<br>Mujhse bas dedo kuch players match jitne 👬👬</blockquote><blockquote>Na jaane yeh kaisa rishta hai,<br>Na jaane yeh kaisa daur hai.<br>Zindagi ke har mod pe,<br>Mere sukoon paane mein tere siwa na chalta kisika zor hai 💙</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c18feb8d6a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Accessibility: Reduce Motion]]></title>
            <link>https://blog.devgenius.io/accessibility-motion-605bee78d809?source=rss-746d5a78d859------2</link>
            <guid isPermaLink="false">https://medium.com/p/605bee78d809</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[accessibility]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swiftui]]></category>
            <dc:creator><![CDATA[Nilaakash Singh]]></dc:creator>
            <pubDate>Sat, 08 Oct 2022 13:08:16 GMT</pubDate>
            <atom:updated>2024-01-07T03:21:26.313Z</atom:updated>
            <content:encoded><![CDATA[<p>This was the area I did not explore in the more extensive time of my career. I consider myself a good developer with accessibility. However, I missed “Reduce Motion” adaptation in most cases.</p><p><strong>Use Case:</strong> This article will help iOS developers to understand, How we can adapt our apps for users who don’t like animations or have some physical problem with animation.</p><p><strong>Prerequisites:</strong></p><ul><li>Basic iOS Swift Knowledge.</li><li>Willing to adapt accessibility enhancements.</li></ul><p><strong>Let’s get started:</strong></p><p>It is possible to reduce motion in iOS from, <br>Settings — Accessibility — Reduce Motion — Toggle on<br> as seen in the below image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JFlrKxnuQJPgGiIA7GK5Uw.png" /><figcaption>Enabling Reduce motion.</figcaption></figure><p>Whenever we see that reducing motion is enabled, it’s recommended to make our animation of the application less or none, including the navigation animation.<br>I’ll write about how to find out if reduce motion is enabled in UIKIT and SwiftUI.</p><p><strong>UIKIT:</strong></p><p>Since UIKIT has been around very long, it is very matured and we can easily figure out if reduce motion is enabled or not with below code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/abe376f1deeb9f727560e977dd171a19/href">https://medium.com/media/abe376f1deeb9f727560e977dd171a19/href</a></iframe><p>SwiftUI:</p><p>We can identify reduce motion using UIKIT accessibility variable or by Environment Property, see below implementation for later concept:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65cebbfcfa2421dc05c5b771fd886850/href">https://medium.com/media/65cebbfcfa2421dc05c5b771fd886850/href</a></iframe><p><strong>Note:</strong> Transaction Approach doesn’t work with Navigation Stack in SwiftUI which can be determined as SwiftUI is still evolving. I will update this article once I get the breakthrough.</p><h3>Verdict:</h3><p>Reduce motion implementation makes our app usable for a more diverse community. Hopefully, this article will help some developers out there explore more in this field.</p><p><strong>Share this blog to spread the knowledge | Do Follow, and CLAP if you Liked it! Happy Coding :)</strong></p><p><strong>Add me on </strong><a href="https://www.linkedin.com/in/nilaakash-singh-79a386b2/"><strong>Linkedin</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=605bee78d809" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/accessibility-motion-605bee78d809">Accessibility: Reduce Motion</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Transforming / Map Operators in Combine Framework]]></title>
            <link>https://blog.devgenius.io/transforming-map-operators-in-combine-framework-2cdc809195c1?source=rss-746d5a78d859------2</link>
            <guid isPermaLink="false">https://medium.com/p/2cdc809195c1</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[combine]]></category>
            <dc:creator><![CDATA[Nilaakash Singh]]></dc:creator>
            <pubDate>Sat, 23 Apr 2022 06:52:01 GMT</pubDate>
            <atom:updated>2024-01-07T03:22:09.297Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article we are going to talk about Transforming which is also called Map operators of Combine Framework in iOS, these operators provide ways to transform data just like collection and filter operators does, they work on a series of data.</p><p><strong>Use Cases: </strong>It is a common programming task to map sets of data. The Combine framework offers many ways to map, filter, and reduce sequences of data, these operations are chained together and a transformation is applied to each element as it passes through the operators, rather than doing the operation on sets of data. <br>I would like to introduce some of the operators in this article and invite you to explore many more that is provided by Combine.</p><p><strong>Prerequisites:</strong></p><ul><li>Xcode 11 and above which supports Combine framework</li><li>Basic knowledge of Publishers, Subscribers, and Subjects.</li></ul><p>Let’s get started:</p><h3>Collect:</h3><p>The collect operator is a publisher that publishes results as an array. This is very useful if you want to break data into contagious data types so that it can be used in a sequence manner. We can also pass an integer as a parameter to chunk the output.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f4112e8efdb080be99d7fbb163fce5d5/href">https://medium.com/media/f4112e8efdb080be99d7fbb163fce5d5/href</a></iframe><p>In the above example, We have used the collect operator twice to show how we can use collect with and without limit.<br>On Line 3, if we don’t have a limit, The publisher will return all the data in a single array.<br>On Line 6, if we set a limit to the collection operator, The publisher will return data in chunks.</p><h3>Replace Nil:</h3><p>As the name suggests this operator is used to replace nil from the set of datasets with provided data. It can be very helpful in case where we get datasets which is not consistent. We can set a fallback by replacing nil with such datasets.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6afa57023ad9cd3ad154c66fdf7e7e8/href">https://medium.com/media/f6afa57023ad9cd3ad154c66fdf7e7e8/href</a></iframe><p>In the above example, We have a small array of alphabets and nil as of the elements. We are making the array as publisher and using “replaceNil” operator with the element “*”, the result in the sink will always have a value that&#39;s why it is force unwrapped.</p><h3>Scan:</h3><p>Scan operator is used to transforming the upstream data into certain sequences of values depending upon the requirement. We have two parameters after we use the scan operator:<br>a. Partial result: First parameter which can be easily accessed on every loop.<br>b. Current element: The second parameter can be used with partial results to a specified pattern.<br>The best part of the scan operator is we can set our return type as shown below in two examples:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/351c806395fc934cb6acf5d98db57a0d/href">https://medium.com/media/351c806395fc934cb6acf5d98db57a0d/href</a></iframe><p>In the above example, we have used a scan operator to return array and integer with different examples. <br>On Line 4 and Line 9 we can see the usage of the scan operator and in the bracket, we have entered the initial value. In the case of an array, it is an empty array and in the case of an integer, it is 0. <br>When we start the closure we get the number and value. The number is previous values whereas the value is the current element instance. We have our custom return type [Int] and Int as per that we are performing operations on Line 5 and 10 respectively.</p><h3>Map:</h3><p>Map operator in Combine works similarly as Map in Swift. It provides a closure where we can add our logic to map data in data sets as per requirement. We are going to look at the map use case twice.<br>Let&#39;s look at the first example below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09826ef30343c576737735a43e1a2234/href">https://medium.com/media/09826ef30343c576737735a43e1a2234/href</a></iframe><p>In the above example, we are using the map operator to convert the array of numbers with spell-out characters. This is just one such use case of map operator. We can also use map for date formatting, adding custom logic to data sets, and so on.</p><h3>Map Keypath:</h3><p>We can also use Map operator to map keys of object. We have seen this usage many times in our day to day programming life but with swift map operator. Combine also provides same sort of map mechanism on publisher so that we can directly operate on upstream.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/93acf7091b261a42eb6704d5cea74c50/href">https://medium.com/media/93acf7091b261a42eb6704d5cea74c50/href</a></iframe><p>In the above example, we have made an object called as Point which has two properties i.e x and y, both are Integer.<br>We are using pass through subject as publisher on line 8 and subscribing it on Line 9. However nothing will print till Line 12 where we actually send object to downstream. <br>This is one of the simplest use case for Map and you can find it similar to swift map.</p><h3>Flat Map:</h3><p>Flat Map operator has similar syntax as flatmap in swift. However, there is a significance difference working with it. Flat map in combine framework is used to combine upstream publishers to single down stream publisher up to max publisher. Max publisher can also be unlimited if not specified.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7238dd5597cd7b2883ac9dbd9bdb0c40/href">https://medium.com/media/7238dd5597cd7b2883ac9dbd9bdb0c40/href</a></iframe><p>In the above example, we are using current value subject as office and 2 objects i.e Village and Town office. <br>- On Line 17 we have used flat map for number of employee on office subject which was initialized to track village office on Line 15.<br>- On Line 20 we have combined now town office object to office subject<br>- Now whenever we change number of employee on both of the object, it will print number of employee on Line 19.</p><p>That’s it from Transforming / Map Operators in Combine Framework. I will be back with one of the most interesting operators in Combine called as “Combining Operators”.</p><h3>Where to go from here:</h3><p>We can try these operators at a time when we are using subscribers to fetch data from the database or server, this will help us to get transformed data and avoid data that is not required at the beginning. You can find the different combined operator and their usage in my <a href="https://github.com/NilaakashSingh/CombineConcepts"><strong>GitHub</strong></a> repository.</p><p><strong>More Reads: <br></strong> <strong>Sequence operators in Combine:</strong> <a href="https://blog.devgenius.io/sequence-operators-in-combine-framework-c942182150a">https://blog.devgenius.io/sequence-operators-in-combine-framework-c942182150a</a></p><p><strong>Filtering Operators in Combine Framework</strong>: <a href="https://medium.com/dev-genius/filtering-operators-in-combine-framework-d51798d4e2a9">https://medium.com/dev-genius/filtering-operators-in-combine-framework-d51798d4e2a9</a></p><p><strong>Share this blog to spread the knowledge | Do Follow, and CLAP if you Liked it! Happy Coding :)</strong></p><p><strong>Add me on </strong><a href="https://www.linkedin.com/in/nilaakash-singh-79a386b2/"><strong>Linkedin</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2cdc809195c1" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/transforming-map-operators-in-combine-framework-2cdc809195c1">Transforming / Map Operators in Combine Framework</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Filtering Operators in Combine Framework]]></title>
            <link>https://blog.devgenius.io/filtering-operators-in-combine-framework-d51798d4e2a9?source=rss-746d5a78d859------2</link>
            <guid isPermaLink="false">https://medium.com/p/d51798d4e2a9</guid>
            <category><![CDATA[combine]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[swiftui]]></category>
            <dc:creator><![CDATA[Nilaakash Singh]]></dc:creator>
            <pubDate>Sat, 05 Mar 2022 14:00:45 GMT</pubDate>
            <atom:updated>2024-01-07T03:22:50.039Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article we are going to talk about filtering operators of Combine Framework in iOS, these operators provide ways to transform data just like collection operators do, but instead they work on a series of data.</p><p><strong>Use Cases: </strong>It is a common programming task to filter sets of data, the same applies to sequences of data. The Combine framework offers many ways to map, filter and reduce sequences of data, these operations are chained together and a transformation is applied to each element as it passes through the operators, rather than doing the operation on sets of data. <br>I would like to introduce some of the operators in this article and invite you to explore many more that is provided by Combine.</p><p><strong>Prerequisites:</strong></p><ul><li>Xcode 11 and above which supports Combine framework</li><li>Basic knowledge of Publishers, Subscribers, and Subjects.</li></ul><p>Let&#39;s get started:</p><h3><strong>Filter:</strong></h3><p>Filter in combine works in the same way as Filter in swift. The only difference here is we can apply a filter even before receiving the value.<br>There are two variations of the filter as seen in the code snippet below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5346fdbed5861af9ef7bd3a37c23981/href">https://medium.com/media/c5346fdbed5861af9ef7bd3a37c23981/href</a></iframe><p>In the above snippet, we have a common publisher on Line 1 which is used to subscribe and filter conditions for both types of filter.</p><blockquote>- For filter we can directly add conditions in closures and sink the result.<br>- For tryFilter we throw the last number exception just for learning purpose and if you observe sink we have receive completion and receive value block. It is required because our filter can also throw exception.</blockquote><h3><strong>Compact Map:</strong></h3><p>Compact Map is a filtering operator used to map the data as per operation. We also have a map in combine but it is part of the Transforming operator. Compact map removes nil elements from the data and publishes non-nil elements when subscribed. <br>We also have a variety of compact map named as <strong>tryCompactMap</strong> which can throw errors when required. You can read more about this variation in <a href="https://developer.apple.com/documentation/combine/publisher/trycompactmap(_:)">Apple Documentation</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e62dba682cedd7301455da5dd8628f97/href">https://medium.com/media/e62dba682cedd7301455da5dd8628f97/href</a></iframe><p>In the above example, We intend to make all the strings in the array as int and then print it. We can easily do it compact without creating an extra variable and then subscribe to it to print the result. <br>As we can see you will not find the result for “<strong>None”</strong> in the output because that will be nil and compact map will skip the stream.</p><h3><strong>Ignore Output:</strong></h3><p>Ignoring Output is a very special kind of operator which ignores all the upstream data but passes the completion state of the publisher. This can be helpful for silent API calls, notifications, or background database sync work where we only need the completion state.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b88d79fc0c8250aec388c93a5b222a9c/href">https://medium.com/media/b88d79fc0c8250aec388c93a5b222a9c/href</a></iframe><p>In the above example, we have made a publisher on Line 2 and we are ignoring output at Line 4. This will not print anything in receive value block but at the end, it will print completion in receive completion block.</p><h3><strong>First and Last:</strong></h3><p>First and Last is also the same as Swift First and Last operator. The only difference is, We will find more variations of first and last in swift compared to Combine.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2002c836214accf3ddab670ee63bd7a7/href">https://medium.com/media/2002c836214accf3ddab670ee63bd7a7/href</a></iframe><p>In the above example we have used First and Last operators on the subscriber which will give results as “1” and “100” respectively. There is variation in first and last called as <strong>“where”</strong>. It will return the first/last element which will satisfy the “<strong>where</strong>” condition.</p><h3><strong>Drop First, Drop While, Drop Until Output From:</strong></h3><p>Drop operator in combine omits the elements in the upstream until the closure result is satisfied. It doesn&#39;t delete the element from memory like we observe in “remove”.<br>There are three variations of drop operator:</p><ol><li>Drop First:<br>Drop First skips the elements from the start till the expression is satisfied. We can use this operator whenever we want to skip initial data.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/53c7211e73961ebd579ae423e2c44e47/href">https://medium.com/media/53c7211e73961ebd579ae423e2c44e47/href</a></iframe><p>In the above example, We can see the simplest we can use drop first operator it will skip the first 2 elements and will print the remaining elements when published.</p><p>2. Drop While:</p><p>Drop While can be used to skip elements with expression. This can be used for showing dataset such as odd, even, multiple, divide, less than, greater than etc.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9132642375d3e77dcacb01b7a8730ab/href">https://medium.com/media/d9132642375d3e77dcacb01b7a8730ab/href</a></iframe><p>In the above example, we have used drop while operator on Line 6 with a less than condition and when subscribe it, the output will be result of skipped elements that satisfies the condition.</p><p>3. Drop Until From:</p><p>Until From is an interesting operator wherever we use it, It takes two subscribers, one for subscribing and one for tracking the subscription.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d960f8ee8ebd8f5fce57cc70db9261f5/href">https://medium.com/media/d960f8ee8ebd8f5fce57cc70db9261f5/href</a></iframe><p>In the above example, We have used 2 subscribers the main subscriber is drop subscriber which is used for subscription. The stopping subscriber is passed on Line 9 defining it as subscriber which can stop subscription. We are stopping the subscription on Line 15 as per condition.</p><h3><strong>Prefix:</strong></h3><p>Prefix can be used to limit the number of data required from a publisher. The can be helpful in pagination&#39;s or in cases where we only need a certain amount of data.<br>There are many variations of a prefix such as <strong>while</strong>, <strong>maxLength</strong>, <strong>untilOutputFrom</strong>, <strong>tryPrefix</strong> which you can easily find in <a href="https://developer.apple.com/documentation/combine/fail/prefix(_:)"><strong>Apple Documentation</strong></a><strong>.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/84abff9b6db551ea1eaa2feb2fd26f6d/href">https://medium.com/media/84abff9b6db551ea1eaa2feb2fd26f6d/href</a></iframe><p>In the above example, we are only using a normal variation of a prefix which will give us the first 7 elements as output.</p><p>Note: There is one more filter operator named as “<strong>Remove duplicates</strong>”. However, I will write about it later.</p><p>That&#39;s all folks with Sequence Operators in Combine. I’ll be back with different combine operators in the next blog.</p><h3>Where to go from here:</h3><p>We can try this operators at a time when we are using subscribers to fetch data from the database or server, this will help us to get filtered data and avoid data which is not required at the beginning. You can find different combine operator and their usage in my <a href="https://github.com/NilaakashSingh/CombineConcepts"><strong>GitHub</strong></a> repository.</p><p><strong>More Reads: <br></strong> <strong>Sequence operators in Combine:</strong> <a href="https://nilaakash.medium.com/sequence-operators-in-combine-framework-c942182150a">https://nilaakash.medium.com/sequence-operators-in-combine-framework-c942182150a</a></p><p><strong>Learning RxSwift and RxCocoa</strong>: <a href="https://medium.com/@iAkashlal/learning-rxswift-and-rxcocoa-basics-with-snippets-e282530d10e7">https://medium.com/@iAkashlal/learning-rxswift-and-rxcocoa-basics-with-snippets-e282530d10e7</a></p><p><strong>Share this blog to spread the knowledge | Do-Follow, and CLAP if you Liked it! Happy Coding :)</strong></p><p><strong>Add me on </strong><a href="https://www.linkedin.com/in/nilaakash-singh-79a386b2/"><strong>Linkedin</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d51798d4e2a9" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/filtering-operators-in-combine-framework-d51798d4e2a9">Filtering Operators in Combine Framework</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sequence Operators in Combine Framework]]></title>
            <link>https://blog.devgenius.io/sequence-operators-in-combine-framework-c942182150a?source=rss-746d5a78d859------2</link>
            <guid isPermaLink="false">https://medium.com/p/c942182150a</guid>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[combine]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Nilaakash Singh]]></dc:creator>
            <pubDate>Mon, 21 Feb 2022 09:51:26 GMT</pubDate>
            <atom:updated>2024-01-07T03:22:29.773Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article we are going to talk about sequence operators of Combine Framework in iOS, that can make your life easy while manipulating data.</p><p><strong>Use Cases: </strong>Different types of sequence operators offered by Combine Framework can be used at a very early stage of data subscription, it can avoid extra calculations for us after getting data.</p><p><strong>Prerequisites:</strong></p><ul><li>Xcode 11 and above which supports Combine framework</li><li>Basic knowledge of Publishers, Subscribers and Subjects.</li></ul><p>Let&#39;s get started:</p><h3><strong>Min and Max:</strong></h3><p>As the name suggests, min and max operators are used to get min and max values from the data types. Let&#39;s see an example below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/041c3ebac4c97d3e258b3db2f1d339c4/href">https://medium.com/media/041c3ebac4c97d3e258b3db2f1d339c4/href</a></iframe><p>In the above example, We have an array of int which is a publisher, when we subscribe it on Line 4 we are using <strong>.min() </strong>operator which will give us a result as -90. Similarly for <strong>.max()</strong> we get output as 200.</p><h3>Reduce:</h3><p>Reduce can help us to get results from operations such as addition, multiplication, subtraction and deletion of elements in the range, array, data structures etc.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/64de49ef092098e626155eb2c32a2384/href">https://medium.com/media/64de49ef092098e626155eb2c32a2384/href</a></iframe><p>In the above example we have made an array of random size and published it on Line 4.</p><p>In Line 5, we are using <strong>reduce() </strong>operator with initial value as “0&quot;. It contains 2 attributes:</p><ul><li>Partial result: It stores operation result after every loop.</li><li>Value: Contains element value on current index of loop.</li></ul><p><em>Loop is nothing but traversing instance on specific index of operation.</em></p><h3><strong>Count:</strong></h3><p>Count can help us get count of published elements. There are two ways we can use count:</p><ul><li>Publishing all elements at once and then checking count.</li><li>Publishing one element at a time and getting counted after finishing the subscription.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8f37d6b9b25fae4b64d3c9dfca1673d/href">https://medium.com/media/d8f37d6b9b25fae4b64d3c9dfca1673d/href</a></iframe><p>In the above example, we can see count is used in both ways. In Line 6 we can use count when we have static elements.</p><p>Starting from Line 9 we have made passthrough subject and on line 10, We have used count operator. If you see the comment on Line 14 we will have to finish the subscription to get the total count.</p><h3>Contains:</h3><p>Contains operator works same as swift. It uses === (pointer comparison) for objects and “==” when it confirms to equatable. We can use it way earlier till we get subscription. We can avoid extra computation while checking different conditions as per logic using this operator.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/91bca4ed7c174b31ebd073bbd3d7bcf3/href">https://medium.com/media/91bca4ed7c174b31ebd073bbd3d7bcf3/href</a></iframe><p>The implementation of this variable is very simple and self explanatory. Line 4 and Line 6 checks for two strings and result differs as per their availability in published variable.</p><h3><strong>AllSatisfy:</strong></h3><p>AllSatisfy is one of my favourite operator in combine sequence operator where we can check a pattern at a very early stage of subscription, this can avoid so many extra calculations at later stage.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/166f77b3854d4debc53cba7079e6ec95/href">https://medium.com/media/166f77b3854d4debc53cba7079e6ec95/href</a></iframe><p>In the above example we’ve made a publisher and we are checking a very basic pattern where different elements are divided by 2 and 3 and remainder should be 0.</p><p>Line 4 will give result as true whereas at Line 5 will the condition will fail. This is where we can discard the usage of above variable/pattern with any work divided by 3.</p><h3>Output:</h3><p>Output operator can be used to get elements at index , in range as per their usage. We can use this variable to get the only result required for our logic.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d81f85a6ba4a610997f48cefb34b26aa/href">https://medium.com/media/d81f85a6ba4a610997f48cefb34b26aa/href</a></iframe><p>In the above example we have used both types of output operator which combine offers.</p><p>Line 3 gives us the output of element at index 3 which is 80. Line 4 gives us the output in range of 0…2, which is “10, 20, 70”.</p><p>Note: First and Last is also available in sequence operators, however I feel it is same as First and Last of Filtering operator of combine which would be my next article.</p><h3>Where to go from here:</h3><p>We can try using this sequence operators at a time when we are using subscribers to get data. You can find different combine operator and their usage in my <a href="https://github.com/NilaakashSingh/CombineConcepts"><strong>GitHub</strong></a> repository.</p><p><strong>Share this blog to spread the knowledge | Do-Follow, and CLAP if you Liked it! Happy Coding :)</strong></p><p><strong>Add me on </strong><a href="https://www.linkedin.com/in/nilaakash-singh-79a386b2/"><strong>Linkedin</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c942182150a" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/sequence-operators-in-combine-framework-c942182150a">Sequence Operators in Combine Framework</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>