<?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"><channel><title><![CDATA[TypeC]]></title><description><![CDATA[TypeC is an ambitious and young writer who's constantly exploring new languages to learn and to teach others. With just a digital tool, TypeC is able to work an]]></description><link>https://typec.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sun, 11 Oct 2026 10:31:24 GMT</lastBuildDate><atom:link href="https://typec.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Exploring GraphQL: A Developer's Perspective]]></title><description><![CDATA[Introduction to GraphQL
In the past, developers had to choose between using REST APIs or SOAP APIs to build their applications. REST APIs were great for simple applications with straightforward data requirements, while SOAP APIs were better suited fo...]]></description><link>https://typec.hashnode.dev/exploring-graphql-a-developers-perspective</link><guid isPermaLink="true">https://typec.hashnode.dev/exploring-graphql-a-developers-perspective</guid><category><![CDATA[GraphQL]]></category><category><![CDATA[Developer]]></category><category><![CDATA[Blogging]]></category><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><dc:creator><![CDATA[TypeC]]></dc:creator><pubDate>Sun, 02 Apr 2023 05:45:17 GMT</pubDate><content:encoded><![CDATA[<h2 id="heading-introduction-to-graphql">Introduction to GraphQL</h2>
<p>In the past, developers had to choose between using REST APIs or SOAP APIs to build their applications. REST APIs were great for simple applications with straightforward data requirements, while SOAP APIs were better suited for more complex applications that required a lot of data processing.</p>
<p>However, as the demands of modern applications grew, developers began to realize that neither REST nor SOAP was sufficient for their needs. They needed something more flexible and powerful that could handle a wide range of data requirements.</p>
<p>Enter GraphQL. GraphQL is a query language and runtime that was developed by Facebook in 2012 and open-sourced in 2015. It allows developers to define a schema that describes their data requirements, and then use that schema to query their APIs for exactly the data they need.</p>
<p>With GraphQL, developers can fetch data from multiple sources in a single request, reduce over-fetching and under-fetching of data, and simplify the process of updating and maintaining APIs over time.</p>
<p>In this blog post, we will explore GraphQL from a developer's perspective, taking a practical approach to understanding its features and best practices for building powerful APIs. Let's dive in!</p>
<h2 id="heading-graphql-schemas-and-types">GraphQL Schemas and Types</h2>
<ul>
<li>Examples of how to define schemas and types in GraphQL</li>
</ul>
<p>In GraphQL, a schema is a blueprint that defines the structure and behavior of an API. It describes the types of data that can be queried and the relationships between them. In other words, a GraphQL schema defines what data can be requested from an API, how it can be requested, and what the response will look like.</p>
<p>A GraphQL schema is composed of two types of components: types and fields. Types define the structure of the data that can be queried or returned by the API. GraphQL has several built-in scalar types, such as Int, String, and Boolean, but it also allows developers to define their custom object types.</p>
<p>For example, if we were building an API for a bookstore, we might define a Book type with fields such as title, author, and publisher. We could also define a Query type, which specifies the entry points for querying the API. The Query type might have a field called books, which returns a list of Book objects.</p>
<p>In addition to custom object types, GraphQL also has input types, which allow for complex input arguments to be passed to queries and mutations. Input types are defined in a similar way to object types but are used for passing arguments to the API rather than returning data.</p>
<p>Overall, schemas and types are crucial components of GraphQL. They enable developers to create APIs that are highly customizable and flexible, allowing applications to query for exactly the data they need. By defining the structure of the data available through the API, developers can reduce the amount of unnecessary data transfer, improving the performance of applications.</p>
<pre><code class="lang-graphql"><span class="hljs-keyword">type</span> Book {
  <span class="hljs-symbol">title:</span> String!
  <span class="hljs-symbol">author:</span> String!
  <span class="hljs-symbol">publisher:</span> String!
}

<span class="hljs-keyword">type</span> Query {
  book(<span class="hljs-symbol">id:</span> ID!): Book!
  <span class="hljs-symbol">books:</span> [Book!]!
}

<span class="hljs-keyword">type</span> Mutation {
  addBook(<span class="hljs-symbol">title:</span> String!, <span class="hljs-symbol">author:</span> String!, <span class="hljs-symbol">publisher:</span> String!): Book!
  updateBook(<span class="hljs-symbol">id:</span> ID!, <span class="hljs-symbol">title:</span> String, <span class="hljs-symbol">author:</span> String, <span class="hljs-symbol">publisher:</span> String): Book!
  deleteBook(<span class="hljs-symbol">id:</span> ID!): Book!
}
</code></pre>
<p>As you can see, we define a Book type with fields for title, author, and publisher. We also define a Query type with two fields: book and books. The book field takes an ID argument and returns a single Book object, while the books field returns a list of Book objects.</p>
<p>We also define a Mutation type with three fields: addBook, updateBook, and deleteBook. The addBook field takes arguments for title, author, and publisher and returns a new Book object. The updateBook field takes an ID argument and optional arguments for title, author, and publisher and returns the updated Book object. The deleteBook field takes an ID argument and returns the deleted Book object.</p>
<p>This demonstrates how to define a GraphQL schema with object types, Query types, and Mutation types. It also shows how to define arguments for queries and mutations, allowing for more flexible and customizable APIs.</p>
<h2 id="heading-resolvers-and-queries">Resolvers and Queries</h2>
<p>Once we have defined our GraphQL schema and types, we need to define how the data will be fetched and resolved. This is where resolvers come into play.</p>
<p>Resolvers are functions that resolve the data for a particular field in a GraphQL query. When a GraphQL query is made, the server calls the appropriate resolver function for each field in the query. The resolver function is responsible for fetching the data for that field and returning it to the client.</p>
<p>Queries are the backbone of GraphQL. They are used to request specific data from a GraphQL API. Each query is made up of one or more fields, which correspond to the fields defined in the schema.</p>
<p>For example, let's say we have a Book type in our schema, with fields for title, author, and publisher. We can define a query to fetch the title and author of a specific book like this:</p>
<pre><code class="lang-graphql"><span class="hljs-keyword">query</span> {
  book(<span class="hljs-symbol">id:</span> <span class="hljs-string">"123"</span>) {
    title
    author
  }
}
</code></pre>
<p>When this query is made, the server will call the book resolver function, passing in the ID argument. The book resolver function will then fetch the data for the specified book and return the title and author fields to the client.</p>
<p>Resolvers can be written in any language or framework, as long as they can be accessed through an API endpoint. They can also be asynchronous, allowing for the use of asynchronous APIs such as databases or web services.</p>
<p>Resolvers and queries are essential components of GraphQL, allowing developers to fetch and resolve data flexibly and efficiently. By defining resolvers for each field in the schema, developers can create APIs that are highly customizable and scalable.</p>
<h2 id="heading-mutations-and-subscriptions">Mutations and Subscriptions</h2>
<p>In addition to queries, GraphQL also supports mutations and subscriptions.</p>
<p>Mutations are used to modify data on the server. They are similar to queries in that they are made up of fields, but they are executed on the server-side rather than just retrieving data. Mutations can be used to create, update, or delete data in the API.</p>
<p>For example, let's say we have a Book type in our schema and we want to add a new book to our database. We can define a mutation like this:</p>
<pre><code class="lang-graphql"><span class="hljs-keyword">mutation</span> {
  addBook(
    <span class="hljs-symbol">title:</span> <span class="hljs-string">"The Great Gatsby"</span>, 
    <span class="hljs-symbol">author:</span> <span class="hljs-string">"F. Scott Fitzgerald"</span>, 
    <span class="hljs-symbol">publisher:</span> <span class="hljs-string">"Scribner"</span>
  ) {
    id
    title
    author
    publisher
  }
}
</code></pre>
<p>When this mutation is made, the server will call the addBook resolver function, passing in the arguments for the new book. The resolver function will then create a new book in the database and return the ID, title, author, and publisher fields of the new book to the client.</p>
<p>Subscriptions are a way to subscribe to real-time updates from the server. They are useful for applications that require real-time data, such as chat applications or social media feeds. Subscriptions are defined in the schema just like queries and mutations, and they use a pub/sub model to deliver real-time updates to the client.</p>
<p>For example, let's say we have a ChatMessage type in our schema and we want to subscribe to new chat messages in real-time. We can define a subscription like this:</p>
<pre><code class="lang-graphql"><span class="hljs-keyword">subscription</span> {
  newMessage(<span class="hljs-symbol">roomId:</span> <span class="hljs-string">"abc"</span>) {
    id
    text
    author
  }
}
</code></pre>
<p>When this subscription is made, the server will subscribe the client to the newMessage event for the specified roomId. Whenever a new chat message is posted in that room, the server will push the ID, text, and author fields of the new message to the client in real-time.</p>
<p>Mutations and subscriptions are powerful features of GraphQL that allow developers to create APIs that are not only flexible and efficient, but also real-time and responsive. By defining mutations for modifying data and subscriptions for real-time updates, developers can create APIs that meet a wide range of use cases and requirements.</p>
<h2 id="heading-best-practices-for-building-powerful-apis-with-graphql">Best Practices for Building Powerful APIs with GraphQL</h2>
<p>Now that we've covered the basics of GraphQL, let's take a look at some best practices for building powerful APIs with GraphQL.</p>
<ol>
<li><p>Keep your schema simple and consistent: A simple and consistent schema makes it easier for clients to understand and use your API. Avoid creating too many nested fields or adding too much complexity to your schema.</p>
</li>
<li><p>Use pagination for large datasets: If your API returns a large amount of data, consider using pagination to improve performance and avoid overwhelming the client with too much data at once.</p>
</li>
<li><p>Use caching to improve performance: Caching can significantly improve the performance of your GraphQL API. Use caching for frequently accessed data to reduce the number of requests to your server.</p>
</li>
<li><p>Secure your API: As with any API, it's important to secure your GraphQL API to prevent unauthorized access and protect sensitive data. Use authentication and authorization to restrict access to certain parts of your API.</p>
</li>
<li><p>Provide detailed documentation: Good documentation is essential for any API. Make sure your GraphQL API is well-documented, with clear descriptions of the schema, types, and fields. Provide examples and use cases to help clients understand how to use your API.</p>
</li>
<li><p>Test your API thoroughly: Thorough testing is important to ensure the reliability and stability of your GraphQL API. Use automated testing to catch errors and ensure that your API behaves as expected.</p>
</li>
<li><p>Keep performance in mind: As with any API, performance is key. Optimize your resolvers and minimize the number of requests required to fulfill a query.</p>
</li>
</ol>
<p>By following these best practices, you can build powerful and efficient GraphQL APIs that are easy to use and provide value to your clients.</p>
<h2 id="heading-real-world-examples-of-graphql-in-action">Real-World Examples of GraphQL in Action</h2>
<p>To get a better sense of how GraphQL is used in the real world, let's take a look at some examples of companies that have implemented GraphQL in their APIs.</p>
<ol>
<li><p>Facebook: Facebook was one of the early adopters of GraphQL and has been using it in production since 2012. They use GraphQL to power their mobile applications, which have complex data requirements and need to be highly performant. By using GraphQL, Facebook can optimize their mobile app data usage, resulting in faster load times and a better user experience.</p>
</li>
<li><p>GitHub: GitHub introduced their GraphQL API in 2016, providing a more flexible and efficient way for developers to access their data. With GraphQL, GitHub can provide developers with a way to retrieve only the data they need, rather than returning a large amount of unnecessary data.</p>
</li>
<li><p>Shopify: Shopify uses GraphQL to power their API, which provides access to data for their e-commerce platform. By using GraphQL, Shopify can provide a flexible and powerful API that can be used by developers to build custom applications and integrations.</p>
</li>
<li><p>The New York Times: The New York Times uses GraphQL to power their website and mobile applications. With GraphQL, they can retrieve data from a variety of sources and provide a consistent and flexible API for their clients.</p>
</li>
<li><p>Yelp: Yelp introduced their GraphQL API in 2020, providing a more efficient way for developers to retrieve data from their platform. With GraphQL, Yelp can provide developers with a way to retrieve only the data they need, resulting in faster and more efficient queries.</p>
</li>
</ol>
<p>These examples demonstrate the power and flexibility of GraphQL in the real world. By using GraphQL, these companies are able to provide more efficient and flexible APIs, resulting in faster load times and a better user experience.</p>
<p>Althought GraphQL isn't here to replace REST, it is still nice to see so many companies adopting this technology. If your company is using GraphQL, do feel free to share it in the comment section below. Until next time 👋</p>
]]></content:encoded></item><item><title><![CDATA[Breaking the Chains of Self-Doubt: Overcoming Imposter Syndrome]]></title><description><![CDATA[Chapter 1: The Unwelcome Guest
I've always been passionate about software engineering. I love the feeling of creating something from scratch and solving complex problems. So, when I landed my dream job at a top tech company, I was thrilled. But as so...]]></description><link>https://typec.hashnode.dev/breaking-the-chains-of-self-doubt-overcoming-imposter-syndrome</link><guid isPermaLink="true">https://typec.hashnode.dev/breaking-the-chains-of-self-doubt-overcoming-imposter-syndrome</guid><category><![CDATA[impostor syndrome]]></category><category><![CDATA[Developer]]></category><category><![CDATA[Software Engineering]]></category><dc:creator><![CDATA[TypeC]]></dc:creator><pubDate>Sat, 01 Apr 2023 01:15:39 GMT</pubDate><content:encoded><![CDATA[<h2 id="heading-chapter-1-the-unwelcome-guest">Chapter 1: The Unwelcome Guest</h2>
<p>I've always been passionate about software engineering. I love the feeling of creating something from scratch and solving complex problems. So, when I landed my dream job at a top tech company, I was thrilled. But as soon as I walked through the doors, I felt like an imposter.</p>
<p>Despite having a strong academic background and experience in the field, I couldn't shake the feeling that I didn't belong. I would look around the office and see colleagues who had years of experience under their belt, and I couldn't help but feel like I didn't measure up.</p>
<p>I tried to brush off my feelings of inadequacy and focus on my work, but they just wouldn't go away. I found myself constantly doubting my abilities and questioning whether I deserved to be there.</p>
<p>Over time, my self-doubt began to take a toll on my mental health. I started to experience anxiety and depression and found it difficult to focus on my work. I was afraid to speak up in meetings or ask for help, for fear of being exposed as a fraud.</p>
<p>But one day, I realized that I couldn't keep living like this. I knew that I needed to confront my feelings of imposter syndrome head-on if I was ever going to succeed in my career.</p>
<p>I started to talk to my colleagues about my struggles and was surprised to find that many of them had experienced imposter syndrome too. I also began to seek out mentorship and support and found that having someone to talk to made all the difference.</p>
<p>As I continued to work on myself and my self-confidence, I began to see my imposter syndrome in a new light. I realized that it was a common experience among high achievers and that I wasn't alone in my feelings.</p>
<p>With time and effort, I was able to break the chains of self-doubt and embrace my true potential as a software engineer. I knew that I still had a lot to learn, but I was no longer afraid to ask questions or seek help. I had overcome my imposter syndrome and was ready to take on whatever challenges came my way.</p>
<h2 id="heading-chapter-2-the-roots-of-self-doubt">Chapter 2: The Roots of Self-Doubt</h2>
<p>As I continued to work on overcoming my imposter syndrome, I realized that I needed to explore the roots of my self-doubt. I needed to understand where these feelings were coming from and how they were holding me back.</p>
<p>I started to reflect on my childhood and upbringing and realized that I had always been a perfectionist. I was taught that nothing less than perfection was acceptable and that any mistake was a failure. This mindset followed me into my adult life, and I found that I was constantly judging myself for every little mistake.</p>
<p>I also realized that I tended to compare myself to others. I would look at my colleagues and see their successes, but completely overlook my own. I was always striving to be better but never took the time to acknowledge my achievements.</p>
<p>To address these roots of self-doubt, I started to practice self-compassion. I learned to be kind to myself and to acknowledge that making mistakes was a natural part of the learning process. I also started to focus on my achievements and celebrate my successes, no matter how small.</p>
<p>In addition, I worked on changing my mindset from a fixed mindset to a growth mindset. Instead of seeing my abilities as fixed, I started to view them as something that could be developed and improved upon. I embraced challenges and sought out opportunities to learn and grow.</p>
<p>These changes didn't happen overnight, but over time I found that they made a significant impact on my self-confidence. I was no longer held back by my own self-doubt and was able to approach my work with a newfound sense of freedom and creativity.</p>
<p>Through this journey of self-discovery, I realized that imposter syndrome was not a reflection of my abilities, but rather a symptom of deeper insecurities. By confronting these roots of self-doubt head-on, I was able to break free from the chains that had held me back for so long.</p>
<h2 id="heading-chapter-3-the-illusion-of-perfection">Chapter 3: The Illusion of Perfection</h2>
<p>As I continued to explore the roots of my self-doubt and work on building my self-confidence, I realized that one of the biggest barriers to my success was the illusion of perfection.</p>
<p>I had always believed that in order to be successful, I had to be perfect. I held myself to impossibly high standards and felt like any mistake was a failure. This mindset had prevented me from taking risks and trying new things, for fear of not being good enough.</p>
<p>I started to recognize that this belief in perfection was holding me back in my career as a software engineer. It was preventing me from taking on challenging projects, trying new technologies, and pushing myself outside of my comfort zone.</p>
<p>To overcome this illusion of perfection, I started to focus on progress over perfection. I realized that success wasn't about being perfect, but rather about making progress toward my goals. I started to set realistic and achievable goals for myself and celebrated each step toward achieving them.</p>
<p>I also started to embrace failure as a necessary part of the learning process. I learned that each mistake was an opportunity to grow and improve, rather than a reflection of my inadequacy. By reframing my mindset, I was able to take on new challenges with more confidence and less fear.</p>
<p>Through this journey, I realized that the pursuit of perfection was a never-ending cycle. No matter how much I achieved, there was always something more that I could do. By letting go of this illusion and embracing progress over perfection, I was able to find more fulfillment in my work and my life.</p>
<p>Breaking the chains of the illusion of perfection was a liberating experience. It allowed me to take risks, try new things, and reach new heights in my career. By embracing progress over perfection, I was able to focus on my growth and development, rather than being held back by my self-doubt.</p>
<h2 id="heading-chapter-4-the-power-of-perspective">Chapter 4: The Power of Perspective</h2>
<p>As I continued to work on overcoming imposter syndrome and building my self-confidence, I realized that the way I perceived myself and my abilities had a profound impact on my success.</p>
<p>I started to recognize that my perspective was shaped by my own beliefs and biases. I had a tendency to focus on my weaknesses and downplay my strengths, which led to feelings of self-doubt and inadequacy.</p>
<p>To change my perspective, I started to focus on my strengths and accomplishments. I made a conscious effort to acknowledge and celebrate my successes, no matter how small. I also sought out feedback from colleagues and mentors and learned to trust their perspectives on my work and abilities.</p>
<p>I also started to challenge my own limiting beliefs and biases. I recognized that my thoughts and beliefs were not always based on reality and that they could be changed with effort and practice. I worked on reframing my thoughts and beliefs to be more positive and empowering, which allowed me to approach challenges with more confidence and less fear.</p>
<p>Through this journey of changing my perspective, I realized that my own beliefs and biases had been holding me back. By shifting my focus to my strengths and accomplishments, and challenging my own limiting beliefs, I was able to break free from the chains of self-doubt and embrace my potential.</p>
<p>I also learned the power of empathy and understanding in shaping my perspective. By putting myself in other people's shoes and trying to see things from their perspective, I was able to build stronger relationships and work more effectively with others. This helped me to see my strengths and weaknesses more objectively and to approach challenges with a more open and collaborative mindset.</p>
<p>The power of perspective was a game-changer for me as a software engineer. By shifting my focus to my strengths, challenging my own limiting beliefs, and practicing empathy and understanding, I was able to approach my work with more confidence and creativity. This allowed me to make meaningful contributions to my team and company, and to reach new heights in my career.</p>
<h2 id="heading-chapter-5-the-courage-to-take-action">Chapter 5: The Courage to Take Action</h2>
<p>As I continued to grow and develop as a software engineer, I realized that one of the biggest obstacles to my success was the fear of taking action.</p>
<p>I had always been cautious and risk-averse, and this had held me back in my career. I would often hold back from speaking up in meetings or taking on new projects, for fear of making a mistake or being judged by others.</p>
<p>To overcome this fear and build my courage, I started to take small steps outside of my comfort zone. I volunteered for projects that were outside of my expertise, and I made a conscious effort to speak up in meetings and share my ideas. I also sought out feedback from colleagues and mentors and used their constructive criticism as an opportunity for growth.</p>
<p>I realized that taking action, even if it meant making mistakes or facing criticism, was a necessary part of growth and development. I learned that by taking risks and pushing myself outside of my comfort zone, I could learn new skills and make meaningful contributions to my team and company.</p>
<p>As I started to take more action and build my courage, I also began to see the benefits in my personal life. I became more confident and assertive in my relationships and was able to set boundaries and express my needs more effectively.</p>
<p>The courage to take action was a transformative experience for me. By facing my fears and taking risks, I was able to reach new heights in my career and personal life. I learned that taking action, even if it meant facing failure or criticism, was a necessary step in achieving success and fulfilling my potential.</p>
<h2 id="heading-chapter-6-the-journey-of-self-discovery">Chapter 6: The Journey of Self-Discovery</h2>
<p>As I continued to work on overcoming imposter syndrome and building my confidence as a software engineer, I realized that this journey was not just about external accomplishments, but also about internal growth and self-discovery.</p>
<p>I started to explore my values, passions, and purpose, and how they related to my work as a software engineer. I began to ask myself questions like: What kind of impact did I want to make in the world? What were my core values and how did they align with the work I was doing? What did I truly enjoy about being a software engineer?</p>
<p>This process of self-discovery was not easy, and it required a lot of reflection, experimentation, and vulnerability. I had to let go of the idea of what I thought I should be doing, and instead focus on what felt authentic and fulfilling to me.</p>
<p>As I went through this journey of self-discovery, I began to see my work in a new light. I started to appreciate the unique skills and perspectives I brought to the table, and how they could be used to make a positive impact in the world. I also began to recognize the importance of work-life balance and self-care, and how they were essential for my personal growth and well-being.</p>
<p>The journey of self-discovery was a transformative experience for me as a software engineer. By exploring my values, passions, and purpose, I was able to align my work with my personal goals and desires. This allowed me to approach my work with a sense of purpose and fulfillment, and to make a meaningful impact in the world.</p>
<p>Through this journey, I also learned the importance of continual growth and self-reflection. I realized that the journey of overcoming imposter syndrome and building confidence was not a one-time event, but rather an ongoing process of learning and self-discovery. I am committed to continually challenging myself, learning new skills, and exploring new opportunities for growth and development.</p>
<p>The journey of self-discovery is a lifelong process, and I am grateful for the experiences and insights I have gained along the way. It has allowed me to not only excel as a software engineer but also to live a more purposeful and fulfilling life.</p>
<h2 id="heading-chapter-7-the-road-ahead">Chapter 7: The Road Ahead</h2>
<p>As I reflect on my journey of overcoming imposter syndrome and building my confidence as a software engineer, I realize that the road ahead is still filled with challenges and opportunities for growth.</p>
<p>While I have made significant progress in building my confidence and pursuing my passions, I know that there will always be new challenges and obstacles to overcome. The field of software engineering is constantly evolving, and I must continue to learn and adapt to stay ahead.</p>
<p>But I am excited about what the future holds. I know that with each challenge comes an opportunity for growth and learning. I am committed to continuing my journey of self-discovery, and to use my skills and talents to make a positive impact in the world.</p>
<p>I am also committed to helping others who may be struggling with imposter syndrome and self-doubt. I know firsthand the impact that these feelings can have on one's career and personal life, and I want to help others overcome these obstacles and reach their full potential.</p>
<p>As I look to the road ahead, I am filled with hope and optimism. I know that there will be ups and downs along the way, but I am confident that with hard work, determination, and a commitment to continual growth and learning, I can achieve my goals and make a meaningful impact in the world.</p>
<h2 id="heading-embracing-your-authentic-self">Embracing Your Authentic Self</h2>
<p>As I reach the end of my journey of overcoming imposter syndrome and building my confidence as a software engineer, I realize that the most important lesson I have learned is the importance of embracing my authentic self.</p>
<p>I have learned that to truly succeed and be fulfilled in my work and personal life, I must be true to myself and my values. I must embrace my strengths and weaknesses, and use them to create a unique and fulfilling path for myself.</p>
<p>This journey has taught me that imposter syndrome and self-doubt are not things to be ashamed of or hidden, but rather opportunities for growth and self-discovery. By acknowledging these feelings and working to overcome them, I have been able to unlock my true potential and live a more fulfilling life.</p>
<p>I hope that my story can serve as inspiration for others who may be struggling with imposter syndrome and self-doubt. I want to encourage everyone to embrace their authentic selves and pursue their passions and dreams with confidence and determination.</p>
<p>Remember that you are capable of achieving great things and that your unique perspectives and experiences are valuable and important. Don't let imposter syndrome hold you back from pursuing your goals and making a positive impact in the world.</p>
<p>Embrace your authentic self, and let your light shine bright.</p>
]]></content:encoded></item><item><title><![CDATA[The Benefits of Using TypeScript in Your Projects]]></title><description><![CDATA[Welcome back to my post about TypeScript. If you're new to TypeScript, check out my previous post here. This will be a very short post on the benefits of TypeScript and why you should use it in your projects.
TypeScript is a powerful programming lang...]]></description><link>https://typec.hashnode.dev/the-benefits-of-using-typescript-in-your-projects</link><guid isPermaLink="true">https://typec.hashnode.dev/the-benefits-of-using-typescript-in-your-projects</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[TypeScript]]></category><category><![CDATA[Developer]]></category><category><![CDATA[React]]></category><dc:creator><![CDATA[TypeC]]></dc:creator><pubDate>Thu, 30 Mar 2023 16:35:39 GMT</pubDate><content:encoded><![CDATA[<p>Welcome back to my post about TypeScript. If you're new to TypeScript, check out my previous post <a target="_blank" href="https://typec.hashnode.dev/getting-started-with-typescript-a-beginners-guide">here</a>. This will be a very short post on the benefits of TypeScript and why you should use it in your projects.</p>
<p>TypeScript is a powerful programming language that adds static type checking to JavaScript, making it easier to catch errors before they happen. Here are some benefits of using TypeScript in your projects:</p>
<ol>
<li><p><strong>Catching Errors Earlier</strong></p>
<p> One of the significant benefits of using TypeScript is its ability to catch errors during compile time. With TypeScript, you can detect and fix potential bugs and errors before you even run your code, which saves you time and effort in debugging later. TypeScript provides strict type checking, which helps you to identify type-related issues early in the development cycle.</p>
</li>
<li><p><strong>Improved Code Readability</strong></p>
<p> TypeScript is a superset of JavaScript that adds strong typing and object-oriented features to the language. It makes your code more maintainable by enforcing strict typing and providing better code organization. The use of types in TypeScript makes it easier for developers to understand the codebase and avoid mistakes while coding.</p>
</li>
<li><p><strong>Enhanced Collaboration</strong></p>
<p> TypeScript's static typing enables better collaboration in teams. TypeScript makes it easier for multiple developers to work on the same codebase by allowing them to understand each other's code better. It helps to reduce conflicts in merging code changes and makes the development process more efficient.</p>
</li>
<li><p><strong>Better IDE Support</strong></p>
<p> TypeScript provides better tooling support than plain JavaScript. It has excellent IDE support, including code completion, refactoring, and debugging. TypeScript's tooling support makes the development process faster and more efficient.</p>
</li>
<li><p><strong>Future-Proofing</strong></p>
<p> TypeScript can lead to better performance because it can help to catch potential performance issues early. TypeScript provides better optimization opportunities, such as removing unnecessary code and inlining functions, which can lead to faster code execution.</p>
</li>
<li><p><strong>Scalability</strong></p>
<p> TypeScript is actively maintained by Microsoft and has a growing community of developers. As a result, it is continually updated with new features and improvements, making it a safe choice for your project's future. By using TypeScript, you can ensure that your codebase stays up-to-date and can take advantage of the latest features and best practices.</p>
</li>
</ol>
<p>Overall, TypeScript offers many benefits to developers, including improved error detection, code readability, collaboration, IDE support, future-proofing, and scalability. If you're not already using TypeScript in your projects, it's definitely worth considering!</p>
<p>Do let me know if I miss out on anything or if the information I provide above is incorrect. Hope you like this article and see you guys in the next one!</p>
]]></content:encoded></item><item><title><![CDATA[Getting Started with TypeScript: A Beginner's Guide]]></title><description><![CDATA[Introduction to TypeScript
TypeScript is a statically-typed superset of JavaScript that was developed by Microsoft in 2012. It adds features to JavaScript such as optional static typing, classes, interfaces, and type annotations that are not availabl...]]></description><link>https://typec.hashnode.dev/getting-started-with-typescript-a-beginners-guide</link><guid isPermaLink="true">https://typec.hashnode.dev/getting-started-with-typescript-a-beginners-guide</guid><category><![CDATA[TypeScript]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[Developer]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[TypeC]]></dc:creator><pubDate>Wed, 29 Mar 2023 16:15:43 GMT</pubDate><content:encoded><![CDATA[<h2 id="heading-introduction-to-typescript">Introduction to TypeScript</h2>
<p>TypeScript is a statically-typed superset of JavaScript that was developed by Microsoft in 2012. It adds features to JavaScript such as optional static typing, classes, interfaces, and type annotations that are not available in JavaScript. TypeScript code is compiled into JavaScript code that can be run in any browser or server environment that supports JavaScript.</p>
<p>The main benefit of TypeScript is that it helps catch errors during the development phase of a project, rather than in production. This is because TypeScript has a type system that checks for type errors at compile time, which can save developers a lot of time and effort in debugging. Additionally, TypeScript code is more maintainable and easier to scale as projects become larger and more complex.</p>
<h2 id="heading-why-use-typescript">Why use Typescript</h2>
<p>There are several reasons why developers might choose to use TypeScript over JavaScript:</p>
<ol>
<li><p>Improved Code Quality: TypeScript can help catch errors and bugs during the development phase, leading to more stable and reliable code.</p>
</li>
<li><p>Better Scalability: TypeScript's strong type system makes it easier to scale projects as they become more complex.</p>
</li>
<li><p>IDE Support: Most popular IDEs, such as Visual Studio Code, has built-in support for TypeScript that can help with code completion, refactoring, and debugging.</p>
</li>
<li><p>Growing Community: TypeScript has a growing community of developers who are actively contributing to the language and building tools and frameworks that make it easier to work with.</p>
</li>
<li><p>Compatibility with JavaScript: TypeScript is a superset of JavaScript, which means that any valid JavaScript code is also valid TypeScript code. This makes it easy to adopt TypeScript in existing projects and gradually introduce it to teams who are familiar with JavaScript.</p>
</li>
</ol>
<h2 id="heading-typescript-basics">Typescript Basics</h2>
<p><strong>Declaring Variables and Data Types</strong></p>
<p>In TypeScript, you can declare variables using the <code>let</code> or <code>const</code> keywords, just like in JavaScript. However, TypeScript also supports explicit type annotations, which can help catch errors and improve code readability.</p>
<p>For example, to declare a variable <code>name</code> of type <code>string</code>, you would write:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">const</span> name: <span class="hljs-built_in">string</span> = <span class="hljs-string">"John"</span>;
</code></pre>
<p>Similarly, to declare a variable <code>age</code> of type <code>number</code>, you would write:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">const</span> age: <span class="hljs-built_in">number</span> = <span class="hljs-number">30</span>;
</code></pre>
<p>TypeScript supports several other basic data types, such as boolean, null, undefined, and any. It also has special types like object, array, and tuple, which allow you to define more complex data structures.</p>
<p><strong>Functions and Parameters</strong></p>
<p>Functions are an essential part of any programming language, and TypeScript is no exception. You can define functions in TypeScript using the <code>function</code> keyword, and you can also specify the data types of the function parameters and return value.</p>
<p>For example, to define a function that takes two parameters <code>x</code> and <code>y</code> of type <code>number</code>, and returns their sum, you would write:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">const</span> add = (x: <span class="hljs-built_in">number</span>, y: <span class="hljs-built_in">number</span>): <span class="hljs-function"><span class="hljs-params">number</span> =&gt;</span> {
    <span class="hljs-keyword">return</span> x + y;
}
</code></pre>
<p>In this example, the function returns a value of type <code>number</code>, which is inferred by TypeScript based on the function definition.</p>
<p>TypeScript also supports optional parameters, default parameter values, and rest parameters, which allow you to define more flexible and powerful functions.</p>
<p>Overall, TypeScript's support for type annotations in variables, parameters, and functions can help catch errors and improve code quality, especially in large and complex projects.</p>
<h2 id="heading-typescript-and-javascript">TypeScript and JavaScript</h2>
<p><strong>Differences between TypeScript and JavaScript</strong></p>
<p>TypeScript and JavaScript share many similarities, but there are also some important differences between them. Some of the key differences include:</p>
<ol>
<li><p>Static Typing: TypeScript allows developers to specify data types for variables, function parameters, and function return values, whereas JavaScript uses dynamic typing.</p>
</li>
<li><p>Interfaces and Classes: TypeScript has support for interfaces and classes, which are not available in JavaScript.</p>
</li>
<li><p>Null and Undefined: TypeScript has strict null and undefined checking, which can help catch errors that might go unnoticed in JavaScript.</p>
</li>
<li><p>Tooling: TypeScript has built-in tooling support for features such as code completion, refactoring, and error checking, which is not available in JavaScript.</p>
</li>
<li><p>Compilation: TypeScript code must be compiled into JavaScript code before it can be run, whereas JavaScript code is executed directly in a browser or server environment.</p>
</li>
</ol>
<p><strong>Converting JavaScript code to TypeScript</strong></p>
<p>One of the benefits of TypeScript is that it is a superset of JavaScript, which means that any valid JavaScript code is also valid TypeScript code. This makes it easy to gradually introduce TypeScript into existing projects, or to convert existing JavaScript code to TypeScript.</p>
<p>To convert JavaScript code to TypeScript, you can start by adding type annotations to variables, function parameters, and function return values. You can also define interfaces and classes to provide more structure and organization to your code.</p>
<p>TypeScript also provides a <code>--checkJs</code> flag, which allows you to check the types of JavaScript code without converting it to TypeScript. This can be useful for gradually introducing TypeScript into existing projects, or for working with third-party JavaScript libraries that don't have TypeScript definitions.</p>
<p>Overall, TypeScript's compatibility with JavaScript, combined with its support for static typing and other advanced features, makes it a powerful tool for improving code quality and productivity in web development projects.</p>
<h2 id="heading-advanced-typescript-features">Advanced TypeScript Features</h2>
<p><strong>Generics</strong></p>
<p>Generics are a powerful feature in TypeScript that allow you to write flexible and reusable code. Generics allow you to define functions, classes, and interfaces that can work with a variety of data types, without sacrificing type safety.</p>
<p>For example, consider the following function that takes an array of numbers and returns the sum of all the numbers:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">const</span> sum = (numbers: <span class="hljs-built_in">number</span>[]): <span class="hljs-function"><span class="hljs-params">number</span> =&gt;</span> {
    <span class="hljs-keyword">let</span> result = <span class="hljs-number">0</span>;
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> num <span class="hljs-keyword">of</span> numbers) {
        result += num;
    }
    <span class="hljs-keyword">return</span> result;
}
</code></pre>
<p>This function works well for arrays of numbers, but what if you want to sum an array of strings or objects? With generics, you can define a more flexible function that works with any data type:</p>
<pre><code class="lang-typescript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">sum</span>&lt;<span class="hljs-title">T</span>&gt;(<span class="hljs-params">items: T[], keyFn: (item: T) =&gt; <span class="hljs-built_in">number</span></span>): <span class="hljs-title">number</span> </span>{
    <span class="hljs-keyword">let</span> result = <span class="hljs-number">0</span>;
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> item <span class="hljs-keyword">of</span> items) {
        result += keyFn(item);
    }
    <span class="hljs-keyword">return</span> result;
}
</code></pre>
<p>In this example, the <code>sum</code> function takes an array of type <code>T</code>, where <code>T</code> is a generic type parameter. The function also takes a second parameter <code>keyFn</code>, which is a function that extracts a numeric value from each item in the array. This allows the <code>sum</code> function to work with any data type that has a numeric property or can be transformed into a numeric value.</p>
<p><strong>Decorators</strong></p>
<p>Decorators are a language feature in TypeScript that allow you to modify the behavior of classes, methods, and properties at runtime. Decorators are a powerful tool for adding additional functionality or behavior to existing code, without the need for complex inheritance or composition.</p>
<p>For example, consider the following class that represents a web API endpoint:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">class</span> ApiEndpoint {
    baseUrl: <span class="hljs-built_in">string</span>;

    <span class="hljs-keyword">constructor</span>(<span class="hljs-params">baseUrl: <span class="hljs-built_in">string</span></span>) {
        <span class="hljs-built_in">this</span>.baseUrl = baseUrl;
    }

    request(path: <span class="hljs-built_in">string</span>, method: <span class="hljs-built_in">string</span>, body?: <span class="hljs-built_in">any</span>): <span class="hljs-built_in">Promise</span>&lt;<span class="hljs-built_in">any</span>&gt; {
        <span class="hljs-keyword">let</span> url = <span class="hljs-built_in">this</span>.baseUrl + path;
        <span class="hljs-keyword">return</span> fetch(url, { method, body }).then(<span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> res.json());
    }
}
</code></pre>
<p>To add caching functionality to this API endpoint, you can define a decorator that caches the response of each API request:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">const</span> cache = <span class="hljs-function">(<span class="hljs-params">
  target: <span class="hljs-built_in">any</span>,
  propertyKey: <span class="hljs-built_in">string</span>,
  descriptor: PropertyDescriptor
</span>) =&gt;</span> {
  <span class="hljs-keyword">let</span> originalMethod = descriptor.value;

  descriptor.value = <span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">...args: <span class="hljs-built_in">any</span>[]</span>) </span>{
    <span class="hljs-keyword">let</span> cacheKey = <span class="hljs-built_in">JSON</span>.stringify(args);
    <span class="hljs-keyword">let</span> cachedResponse = sessionStorage.getItem(cacheKey);
    <span class="hljs-keyword">if</span> (cachedResponse) {
      <span class="hljs-keyword">return</span> <span class="hljs-built_in">JSON</span>.parse(cachedResponse);
    } <span class="hljs-keyword">else</span> {
      <span class="hljs-keyword">let</span> response = <span class="hljs-keyword">await</span> originalMethod.apply(<span class="hljs-built_in">this</span>, args);
      sessionStorage.setItem(cacheKey, <span class="hljs-built_in">JSON</span>.stringify(response));
      <span class="hljs-keyword">return</span> response;
    }
  };

  <span class="hljs-keyword">return</span> descriptor;
}

<span class="hljs-keyword">class</span> ApiEndpoint {
  baseUrl: <span class="hljs-built_in">string</span>;

  <span class="hljs-keyword">constructor</span>(<span class="hljs-params">baseUrl: <span class="hljs-built_in">string</span></span>) {
    <span class="hljs-built_in">this</span>.baseUrl = baseUrl;
  }

  <span class="hljs-meta">@cache</span>
  <span class="hljs-keyword">async</span> request(path: <span class="hljs-built_in">string</span>, method: <span class="hljs-built_in">string</span>, body?: <span class="hljs-built_in">any</span>): <span class="hljs-built_in">Promise</span>&lt;<span class="hljs-built_in">any</span>&gt; {
    <span class="hljs-keyword">let</span> url = <span class="hljs-built_in">this</span>.baseUrl + path;
    <span class="hljs-keyword">return</span> fetch(url, { method, body }).then(<span class="hljs-function">(<span class="hljs-params">res</span>) =&gt;</span> res.json());
  }
}
</code></pre>
<p>In this example, the <code>cache</code> decorator takes three parameters: the target class, the property name, and the property descriptor. The decorator modifies the behavior of the <code>request</code> method by wrapping it with a caching mechanism. This allows the <code>ApiEndpoint</code> class to have caching functionality without modifying the original <code>request</code> method.</p>
<p>Overall, TypeScript's support for advanced language features such as generics and decorators makes it a powerful tool for building complex and scalable web applications.</p>
<h2 id="heading-building-and-running-typescript-code">Building and Running TypeScript Code</h2>
<p><strong>Setting up the Development Environment</strong></p>
<p>To build and run TypeScript code, you'll need to set up a development environment with the necessary tools and packages installed. Here are the basic steps to get started:</p>
<ol>
<li><p>Install Node.js: TypeScript is built on top of Node.js, so you'll need to install it if you don't already have it installed on your system. You can download the latest version of Node.js from the official website.</p>
</li>
<li><p>Install TypeScript: Once you have Node.js installed, you can install TypeScript using the Node Package Manager (npm). Open a terminal or command prompt and run the following command: <code>npm install -g typescript</code>. This will install the latest version of TypeScript globally on your system.</p>
</li>
<li><p>Create a TypeScript project: To start a new TypeScript project, create a new directory for your project and navigate to it in the terminal. Then, run the following command: <code>tsc --init</code>. This will create a new <code>tsconfig.json</code> file in your project directory, which is used to configure the TypeScript compiler.</p>
</li>
<li><p>Write your TypeScript code: With your development environment set up, you can now start writing TypeScript code in a <code>.ts</code> file. When you're ready to build and run your code, you'll need to compile it to JavaScript using the TypeScript compiler.</p>
</li>
</ol>
<p><strong>Compiling TypeScript Code</strong></p>
<p>To compile TypeScript code to JavaScript, you'll need to use the TypeScript compiler (<code>tsc</code>). The compiler takes your TypeScript code and transforms it into JavaScript code that can be executed in a web browser or a Node.js environment.</p>
<p>To compile your TypeScript code, navigate to the directory where your <code>.ts</code> file is located and run the following command: <code>tsc</code>. This will compile your TypeScript code to JavaScript and create a new <code>.js</code> file in the same directory. By default, the compiler will use the <code>tsconfig.json</code> file in your project directory to determine how to compile your code.</p>
<p>You can also watch your TypeScript files for changes and automatically recompile your code whenever you save your changes. To do this, run the following command: <code>tsc --watch</code>. This will start the TypeScript compiler in watch mode, which will automatically recompile your code whenever you make changes to your <code>.ts</code> files.</p>
<p><strong>Running TypeScript Code</strong></p>
<p>Once you've compiled your TypeScript code to JavaScript, you can run it in a web browser or a Node.js environment, depending on the type of application you're building.</p>
<p>To run your TypeScript code in a web browser, you'll need to include the compiled JavaScript file in an HTML file and load it in the browser. For example, you might have an <code>index.html</code> file that includes a <code>&lt;script&gt;</code> tag with the path to your compiled JavaScript file.</p>
<p>To run your TypeScript code in a Node.js environment, you can use the Node.js command line interface to execute the compiled JavaScript file. For example, if your compiled JavaScript file is named <code>app.js</code>, you can run it using the following command: <code>node app.js</code>.</p>
<p>Overall, building and running TypeScript code requires a bit of setup and configuration, but once you have your development environment set up and your code compiled, you can run it in a variety of different environments and platforms.</p>
<h2 id="heading-typescript-tools-and-resources">TypeScript Tools and Resources</h2>
<p><strong>TypeScript Editors and IDEs</strong></p>
<p>One of the great things about TypeScript is that it integrates seamlessly with many popular code editors and IDEs. Here are some of the most popular tools for working with TypeScript:</p>
<ol>
<li><p>Visual Studio Code: Visual Studio Code is a lightweight and powerful code editor that offers excellent support for TypeScript. The editor includes features like syntax highlighting, code completion, and debugging tools that make it easy to write and debug TypeScript code.</p>
</li>
<li><p>WebStorm: WebStorm is a full-featured IDE that offers robust support for TypeScript. The IDE includes features like intelligent code completion, refactoring tools, and built-in debugging that make it easy to write and debug TypeScript code.</p>
</li>
<li><p>Sublime Text: Sublime Text is a lightweight and customizable code editor that offers excellent support for TypeScript. The editor includes features like syntax highlighting, code completion, and multiple cursors that make it easy to write TypeScript code.</p>
</li>
<li><p>Atom: Atom is a free and open-source code editor that offers excellent support for TypeScript. The editor includes features like syntax highlighting, code completion, and a powerful package ecosystem that make it easy to write TypeScript code.</p>
</li>
</ol>
<p><strong>TypeScript Resources</strong></p>
<p>In addition to editors and IDEs, there are many other resources available for learning and working with TypeScript. Here are some of the most useful resources for TypeScript developers:</p>
<ol>
<li><p><a target="_blank" href="https://www.typescriptlang.org/docs/">TypeScript Documentation</a>: The official TypeScript documentation is an excellent resource for learning about the language and its features. The documentation includes guides, reference materials, and examples that cover everything from basic syntax to advanced features like decorators and mixins.</p>
</li>
<li><p><a target="_blank" href="https://www.typescriptlang.org/docs/handbook/intro.html">TypeScript Handbook</a>: The TypeScript Handbook is a comprehensive guide to the language that covers everything from basic types and variables to advanced features like generics and conditional types. The handbook is an excellent resource for both beginners and experienced TypeScript developers.</p>
</li>
<li><p><a target="_blank" href="https://www.typescriptlang.org/play">TypeScript Playground</a>: The TypeScript Playground is an online tool that allows you to experiment with TypeScript code and see the results in real-time. The playground includes a code editor, compiler, and output panel that make it easy to test and debug TypeScript code.</p>
</li>
<li><p><a target="_blank" href="https://github.com/DefinitelyTyped">DefinitelyTyped</a>: DefinitelyTyped is a repository of TypeScript type definitions for popular JavaScript libraries and frameworks. The repository includes definitions for everything from React and Angular to jQuery and underscore.js, making it easy to add TypeScript support to your existing projects.</p>
</li>
</ol>
<p>Overall, there are many great tools and resources available for working with TypeScript, whether you're a beginner just getting started with the language or an experienced developer looking to take your skills to the next level.</p>
<h2 id="heading-conclusion-and-next-steps">Conclusion and Next Steps</h2>
<p><strong>Conclusion</strong></p>
<p>In this article, we've covered the basics of TypeScript, including its features, benefits, and how to get started with the language. We've also explored some of the more advanced features of TypeScript, such as generics, interfaces, and decorators. Additionally, we've discussed some of the most useful tools and resources for working with TypeScript, including editors and IDEs, the TypeScript documentation, and the DefinitelyTyped repository.</p>
<p>Overall, TypeScript is a powerful and flexible language that can help you write more robust and maintainable code. Whether you're working on a large-scale project or a small personal project, TypeScript can help you catch errors early, write more expressive code, and make your code more maintainable over time.</p>
<p><strong>Next Steps</strong></p>
<p>If you're new to TypeScript, the next step is to start experimenting with the language and building small projects. Try building a simple web app or library using TypeScript and see how it compares to writing the same code in JavaScript. You may find that TypeScript helps you catch errors earlier and write more expressive code.</p>
<p>As you become more comfortable with TypeScript, consider exploring some of its more advanced features, such as decorators, mixins, and conditional types. These features can help you write more complex and flexible code and can be especially useful for building large-scale projects.</p>
<p>Finally, don't forget to take advantage of the many tools and resources available for working with TypeScript, including editors and IDEs, the TypeScript documentation, and the DefinitelyTyped repository. These resources can help you become a more productive and effective TypeScript developer and can help you take your skills to the next level.</p>
<p>I hope this helps you get started on your TypeScript beginner's guide! Don't hesitate to let me know in the comment section if you have any other questions or need more help.</p>
]]></content:encoded></item><item><title><![CDATA[How to easily create URL parameters using searchParams in JavaScript]]></title><description><![CDATA[What are URL parameters?
URL parameters are just a way to send information to perform certain tasks such as filtering, sorting, translating, describing etc.

❌ How do we do it?
You might have seen people encoding URL parameters like this
const url = ...]]></description><link>https://typec.hashnode.dev/how-to-easily-create-url-parameters-using-searchparams-in-javascript</link><guid isPermaLink="true">https://typec.hashnode.dev/how-to-easily-create-url-parameters-using-searchparams-in-javascript</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[HTML5]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[tutorials]]></category><dc:creator><![CDATA[TypeC]]></dc:creator><pubDate>Sun, 29 Jan 2023 04:44:25 GMT</pubDate><content:encoded><![CDATA[<h2 id="heading-what-are-url-parameters">What are URL parameters?</h2>
<p>URL parameters are just a way to send information to perform certain tasks such as filtering, sorting, translating, describing etc.</p>
<p><img src="https://static.semrush.com/blog/uploads/media/5a/20/5a20dd9a3859e973f5a378a1d6f96a9f/Graphic%201.png" alt="img-semblog" /></p>
<h2 id="heading-httpsemojipediaorgcross-mark-how-do-we-do-it"><a target="_blank" href="https://emojipedia.org/cross-mark/">❌</a> How do we do it?</h2>
<p>You might have seen people encoding URL parameters like this</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> url = <span class="hljs-string">"https://website.com/"</span> + <span class="hljs-string">"?filter="</span> + <span class="hljs-built_in">encodeURIComponent</span>(filter) + <span class="hljs-string">"&amp;sort="</span> + <span class="hljs-built_in">encodeURIComponent</span>(sort)
</code></pre>
<p>This works but can complicate things if you have many URL parameters to encode and it might not be readable to other developers.</p>
<h2 id="heading-how-do-we-do-it">✅ <strong>How do we do it?</strong></h2>
<p>You can simplify doing things like this</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> url = <span class="hljs-keyword">new</span> URL(<span class="hljs-string">"https://website.com/"</span>)

url.searchParams.set(<span class="hljs-string">"filter"</span>, filter)
url.searchParams.set(<span class="hljs-string">"sort"</span>, sort)
url.toString()
</code></pre>
<p>That's it! See how simple and readable this code is? I hope you enjoyed this short tutorial.</p>
]]></content:encoded></item><item><title><![CDATA[Lazy loading images in Web Development]]></title><description><![CDATA[What is lazy loading?
Simply put, you're loading resources only when you need to. This can significantly reduce bandwidth wastage for you and your users.
How do we do it?
Simple. All browsers using the latest version should already have built-in supp...]]></description><link>https://typec.hashnode.dev/lazy-loading-images-in-web-development</link><guid isPermaLink="true">https://typec.hashnode.dev/lazy-loading-images-in-web-development</guid><category><![CDATA[HTML5]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[optimization]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[tutorials]]></category><dc:creator><![CDATA[TypeC]]></dc:creator><pubDate>Sun, 29 Jan 2023 04:30:35 GMT</pubDate><content:encoded><![CDATA[<h2 id="heading-what-is-lazy-loading">What is lazy loading?</h2>
<p>Simply put, you're loading resources only when you need to. This can significantly reduce bandwidth wastage for you and your users.</p>
<h2 id="heading-how-do-we-do-it">How do we do it?</h2>
<p>Simple. All browsers using the latest version should already have built-in support for lazy loading images. Here's how you can do it</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"/image.png"</span> <span class="hljs-attr">loading</span>=<span class="hljs-string">"lazy"</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">iframe</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"/iframe.html"</span> <span class="hljs-attr">loading</span>=<span class="hljs-string">"lazy"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">iframe</span>&gt;</span>
</code></pre>
<h2 id="heading-how-does-it-work">How does it work?</h2>
<p>Here's how it works. All the resources that have the attribute <code>loading="lazy"</code> will only load when the resource is visible in the viewport. This means that the browser will only start downloading the resource when it's visible. This can help optimize your web application's bandwidth usage.</p>
<p>That's it for today. Hope you enjoy reading this short tutorial. Until next time~</p>
]]></content:encoded></item><item><title><![CDATA[Easily make files downloadable without JavaScript]]></title><description><![CDATA[Ever wonder how you can easily create a downloadable file without any JavaScript? You can easily do so by adding the download attribute to your anchor tag. You can learn more about it [here](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a...]]></description><link>https://typec.hashnode.dev/easily-make-files-downloadable-without-javascript</link><guid isPermaLink="true">https://typec.hashnode.dev/easily-make-files-downloadable-without-javascript</guid><category><![CDATA[React]]></category><category><![CDATA[HTML5]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[TypeC]]></dc:creator><pubDate>Sun, 29 Jan 2023 04:18:38 GMT</pubDate><content:encoded><![CDATA[<p>Ever wonder how you can easily create a downloadable file without any JavaScript? You can easily do so by adding the <code>download</code> attribute to your <code>anchor</code> tag. You can learn more about it [here](<a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download">https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download</a>)</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"/file.pdf"</span> <span class="hljs-attr">download</span>&gt;</span>Download PDF File<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>

or

<span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"/link to file"</span> <span class="hljs-attr">download</span>=<span class="hljs-string">"/file.pdf"</span>&gt;</span>Download PDF File<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
</code></pre>
<p>Isn't this cool? You can easily create a downloadable link without using any JavaScript. However, one downside of this is it blocks cross-origin links. If you really need to use cross-origin links, you will have to use JavaScript to force the download. That's all for today. Until next time!</p>
<p>#html #download #tutorial</p>
]]></content:encoded></item><item><title><![CDATA[What is useContext and how to use it?]]></title><description><![CDATA[Introduction
What is useContext?
useContext is a React hook provided to allow you to manage a global state throughout the components tree in your React application without the need to use any 3rd party library such as Redux to manage your states for ...]]></description><link>https://typec.hashnode.dev/what-is-usecontext-and-how-to-use-it</link><guid isPermaLink="true">https://typec.hashnode.dev/what-is-usecontext-and-how-to-use-it</guid><category><![CDATA[React]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[ReactHooks]]></category><dc:creator><![CDATA[TypeC]]></dc:creator><pubDate>Fri, 29 Apr 2022 15:27:41 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1651242219316/pJ1XXeL3V.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<h2 id="heading-what-is-usecontext">What is useContext?</h2>
<p>useContext is a React hook provided to allow you to manage a global state throughout the components tree in your React application without the need to use any 3rd party library such as Redux to manage your states for you. Before useContext was introduced, we can only manage a global state using third party libraries such as Redux, MobX, Recoil or just use props drilling.</p>
<h2 id="heading-why-use-react-hooks-if-there-are-already-libraries-to-do-it">Why use React hooks if there are already libraries to do it?</h2>
<p>The reason is because, third party libraries such as Redux, MobX and Recoil has a high learning curve and it can be very confusing to you if you implement it wrongly. I'm not saying that it's bad but using a third party library to handle state management can be overkill to small applications such as your to-do app :p Of course, having a third library state management is ideal if you're planning to build an industry standard application that scales well. For now, let's just focus on how we can use React hooks to better manage our states for small to medium applications.</p>
<h1 id="heading-getting-started">Getting started</h1>
<p>Now that we got the introduction out of the way, let's starting coding!</p>
<pre><code><span class="hljs-comment">// context.js</span>
<span class="hljs-keyword">import</span> <span class="hljs-title">React</span>, { <span class="hljs-title">useState</span>, <span class="hljs-title">createContext</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"react"</span>;

<span class="hljs-comment">// Creates a context for your React app to use</span>
export const AppContext <span class="hljs-operator">=</span> createContext({});
export const AppProvider <span class="hljs-operator">=</span> (props) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
  const [counter, setCounter] <span class="hljs-operator">=</span> useState(<span class="hljs-number">0</span>);

  <span class="hljs-keyword">return</span> (
    <span class="hljs-operator">&lt;</span>AppContext.Provider
      value<span class="hljs-operator">=</span>{{
        appState,
        setAppState,
      }}
    <span class="hljs-operator">&gt;</span>
      {props.children}
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>AppContext.Provider&gt;
  );
};
</code></pre><pre><code><span class="hljs-comment">// _app.js</span>
<span class="hljs-keyword">import</span> { <span class="hljs-title">AppProvider</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"./context.js"</span>;

<span class="hljs-comment">// Encapsulate your AppProvider so that your global state will always</span>
<span class="hljs-comment">// be accessible no matter how deep the component tree is</span>
const MyApp <span class="hljs-operator">=</span> ({ Component, pageProps }) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
     <span class="hljs-operator">&lt;</span>AppProvider<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>Component {...pageProps} <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
     <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>AppProvider<span class="hljs-operator">&gt;</span>
}
</code></pre><pre><code><span class="hljs-comment">// counter.js</span>
<span class="hljs-keyword">import</span> { <span class="hljs-title">useContext</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">AppContext</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"./context.js"</span>;

const Counter <span class="hljs-operator">=</span> () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
    <span class="hljs-comment">// useContext hook is called here to tell React that you want to </span>
    <span class="hljs-comment">// use AppContext to handle the state in your appliction. This will</span>
    <span class="hljs-comment">// fetch the current state from the context, in this case, the counter.</span>
    const { counter, setCounter } <span class="hljs-operator">=</span> useContext(AppContext);

    <span class="hljs-keyword">return</span> (
        <span class="hljs-operator">&lt;</span>div<span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">&lt;</span>p<span class="hljs-operator">&gt;</span>{counter}<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>p<span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">&lt;</span>button onClick<span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span>{() <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> setCounter(counter <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-number">1</span>)}<span class="hljs-operator">&gt;</span>
                <span class="hljs-operator">+</span><span class="hljs-number">1</span>
            <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>button<span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
    )
}

export default Counter;
</code></pre><h1 id="heading-conclusion">Conclusion</h1>
<p>Now that you know how React useContext works, you can start implementing this to your application. React's useContext hook is very useful and allows you to easily manage states for small to medium applications. It's actually not that different from the useState hook as you can see the similarities in the code structure. I hope that this short tutorial can help you to better understand why useContext is useful and how it can make your code a lot cleaner and organised :) Feel free to leave your questions in the comment section and I'll be more than happy to answer them.</p>
]]></content:encoded></item><item><title><![CDATA[List of known ERC standards in 2022]]></title><description><![CDATA[Ever wondered what each ERC standards means? Why some NFT uses ERC-20 while others uses ERC-721? Don't worry! Today, I'm here to break it down for you and to make it as simple as possible ❤️
ERC-20 - Token Standard
This token standard 

Enables token...]]></description><link>https://typec.hashnode.dev/list-of-known-erc-standards-in-2022</link><guid isPermaLink="true">https://typec.hashnode.dev/list-of-known-erc-standards-in-2022</guid><category><![CDATA[Ethereum]]></category><category><![CDATA[Developer Tools]]></category><category><![CDATA[Smart Contracts]]></category><category><![CDATA[documentation]]></category><dc:creator><![CDATA[TypeC]]></dc:creator><pubDate>Fri, 18 Mar 2022 04:13:21 GMT</pubDate><content:encoded><![CDATA[<p>Ever wondered what each ERC standards means? Why some NFT uses ERC-20 while others uses ERC-721? Don't worry! Today, I'm here to break it down for you and to make it as simple as possible ❤️</p>
<h2 id="heading-erc-20-token-standard">ERC-20 - Token Standard</h2>
<p>This token standard </p>
<ul>
<li>Enables tokens to be transferred to another wallet</li>
<li>Get the current token balance from a wallet</li>
<li>Get the total supply of a token</li>
<li>Allow tokens to be approved on on-chain apps to be spent on the platform. </li>
</ul>
<h3 id="heading-example">Example</h3>
<p>Here's an example of how you can use it</p>
<pre><code><span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.8.10;</span>

<span class="hljs-keyword">import</span> <span class="hljs-string">"https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.0.0/contracts/token/ERC20/ERC20.sol"</span>;

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">GMToken</span> <span class="hljs-keyword">is</span> <span class="hljs-title">ERC20</span> </span>{
    <span class="hljs-comment">// Constructo takes in a name and symbol for your token which will then pass</span>
   <span class="hljs-comment">// to ERC20 constructor during initialisation</span>
    <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"><span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span> name, <span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span> symbol</span>) <span class="hljs-title">ERC20</span>(<span class="hljs-params">name, symbol</span>) </span>{
         <span class="hljs-comment">// Mint 100 tokens to msg.sender</span>
        <span class="hljs-comment">// Similar to how</span>
        <span class="hljs-comment">// 1 dollar = 100 cents</span>
        <span class="hljs-comment">// 1 token = 1 * (10 ** decimals)</span>
        _mint(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>, <span class="hljs-number">100</span> <span class="hljs-operator">*</span> <span class="hljs-number">10</span><span class="hljs-operator">*</span><span class="hljs-operator">*</span><span class="hljs-keyword">uint</span>(decimals()));
    }
}
</code></pre><blockquote>
<p>You can learn more about it https://solidity-by-example.org/app/erc20/</p>
</blockquote>
<h2 id="heading-erc-721-nft-standard">ERC-721 - NFT Standard</h2>
<p>This is a standard for creating NFTs which ensures that all tokens generated from the same contract is unique. This is usually used to create a NFT collection where users are given an opportunity to mint some NFTs from the collection. </p>
<h3 id="heading-example">Example</h3>
<p>Here's an example of how you can use it</p>
<pre><code><span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.8.10;</span>
<span class="hljs-keyword">import</span> <span class="hljs-string">"@openzeppelin/contracts/token/ERC721/ERC721.sol"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">"@openzeppelin/contracts/drafts/Counters.sol"</span>;

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">ETHGame</span> <span class="hljs-keyword">is</span> <span class="hljs-title">ERC721</span> </span>{
    <span class="hljs-keyword">using</span> <span class="hljs-title">Counters</span> <span class="hljs-title"><span class="hljs-keyword">for</span></span> <span class="hljs-title">Counters</span>.<span class="hljs-title">Counter</span>;
    Counters.Counter <span class="hljs-keyword">private</span> _tokenIds;
    <span class="hljs-keyword">mapping</span>(<span class="hljs-keyword">address</span> <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> <span class="hljs-keyword">uint256</span>) <span class="hljs-keyword">public</span> nftHolders;

    <span class="hljs-comment">// This will create a custom name and symbol for your NFT token</span>
    <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"></span>) <span class="hljs-title">ERC721</span>(<span class="hljs-params"><span class="hljs-string">"ETHGame"</span>, <span class="hljs-string">"ETHG"</span></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> </span>{
    }

    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">mintCharacter</span>(<span class="hljs-params"><span class="hljs-keyword">uint256</span> _index</span>) <span class="hljs-title"><span class="hljs-keyword">external</span></span> </span>{
        <span class="hljs-keyword">uint256</span> newId <span class="hljs-operator">=</span> _tokenIds.current(); <span class="hljs-comment">// Returns the current ID</span>
        _safeMint(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>, newId);   <span class="hljs-comment">// Mints a new ID to the sender's address</span>
        nftHolders[<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>] <span class="hljs-operator">=</span> newId;  <span class="hljs-comment">// This assigns the new ID to your account address</span>
        _tokenIds.increment();  <span class="hljs-comment">// This increases the tokenId every time there's a successful mint</span>
    }
}
</code></pre><blockquote>
<p>You can read more about it here https://ethereum.org/en/developers/docs/standards/tokens/erc-721/</p>
</blockquote>
<h2 id="heading-erc-777-token-standard">ERC-777 - Token Standard</h2>
<p>This is a new standard that defines advanced features to interact with tokens such as</p>
<ul>
<li>Sending tokens on behalf of another address either for contract or regular account</li>
<li>Send/receive hooks to offer token holders more control over their tokens</li>
<li>Backward compatible with ERC-20 tokens</li>
</ul>
<h3 id="heading-example">Example</h3>
<pre><code><span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.6.0;</span>

<span class="hljs-keyword">import</span> <span class="hljs-string">"@openzeppelin/contracts/token/ERC777/ERC777.sol"</span>;


<span class="hljs-comment">/**
 * @title Simple777Token
 * @dev Very simple ERC777 Token example, where all tokens are pre-assigned to the creator.
 * Note they can later distribute these tokens as they wish using `transfer` and other
 * `ERC20` or `ERC777` functions.
 * Based on https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/examples/SimpleToken.sol
 */</span>
<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">Simple777Token</span> <span class="hljs-keyword">is</span> <span class="hljs-title">ERC777</span> </span>{

    <span class="hljs-comment">/**
     * @dev Constructor that gives msg.sender all of existing tokens.
     */</span>
    <span class="hljs-function"><span class="hljs-keyword">constructor</span> (<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title">ERC777</span>(<span class="hljs-params"><span class="hljs-string">"Simple777Token"</span>, <span class="hljs-string">"S7"</span>, <span class="hljs-keyword">new</span> <span class="hljs-keyword">address</span>[](<span class="hljs-params"><span class="hljs-number">0</span></span>)</span>) </span>{
        _mint(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>, <span class="hljs-number">10000</span> <span class="hljs-operator">*</span> <span class="hljs-number">10</span> <span class="hljs-operator">*</span><span class="hljs-operator">*</span> <span class="hljs-number">18</span>, <span class="hljs-string">""</span>, <span class="hljs-string">""</span>);
    }
}

<span class="hljs-comment">// Example taken from https://github.com/abcoathup/Simple777Token/blob/master/contracts/Simple777Token.sol</span>
</code></pre><blockquote>
<p>You can learn more about it here https://ethereum.org/en/developers/docs/standards/tokens/erc-777/</p>
</blockquote>
<h2 id="heading-erc-1155-multi-token-standard">ERC-1155 - Multi-Token Standard</h2>
<p>The goal is to create a simple and flexible smart contract interface that can handle different token types. This will allow the ERC-1155 token to perform the same functions as both the ERC-20 and the ERC-721.</p>
<blockquote>
<p>You can learn more about it here https://ethereum.org/en/developers/docs/standards/tokens/erc-1155/</p>
</blockquote>
<h3 id="heading-example">Example</h3>
<pre><code>ERC1155

ERC1155 <span class="hljs-keyword">is</span> a novel token standard that aims to take the best <span class="hljs-keyword">from</span> previous standards to create a fungibility<span class="hljs-operator">-</span>agnostic and gas<span class="hljs-operator">-</span>efficient token <span class="hljs-keyword">contract</span>.
    ERC1155 draws ideas <span class="hljs-keyword">from</span> all of ERC20, ERC721, and ERC777. If you’re unfamiliar with those standards, head to their guides before moving on.
Multi Token Standard

The distinctive feature of ERC1155 <span class="hljs-keyword">is</span> that it uses a single smart <span class="hljs-keyword">contract</span> to represent multiple tokens at once. This <span class="hljs-keyword">is</span> why its balanceOf <span class="hljs-keyword">function</span> differs <span class="hljs-keyword">from</span> ERC20’s and ERC777’s: it has an additional id argument <span class="hljs-keyword">for</span> the identifier of the token that you want to query the balance of.

This <span class="hljs-keyword">is</span> similar to how ERC721 does things, but in that standard a token id has no concept of balance: each token <span class="hljs-keyword">is</span> non-fungible and exists or doesn’t. The ERC721 balanceOf <span class="hljs-keyword">function</span> refers to how many different tokens an account has, not how many of each. On the other hand, in ERC1155 accounts have a distinct balance <span class="hljs-keyword">for</span> each token id, and non-fungible tokens are implemented by simply minting a single one of them.

This approach leads to massive gas savings <span class="hljs-keyword">for</span> projects that <span class="hljs-built_in">require</span> multiple tokens. Instead of deploying a <span class="hljs-keyword">new</span> <span class="hljs-keyword">contract</span> <span class="hljs-keyword">for</span> each token <span class="hljs-keyword">type</span>, a single ERC1155 token <span class="hljs-keyword">contract</span> can hold the entire system state, reducing deployment costs and complexity.
Batch Operations

Because all state <span class="hljs-keyword">is</span> held in a single <span class="hljs-keyword">contract</span>, it <span class="hljs-keyword">is</span> possible to operate over multiple tokens in a single transaction very efficiently. The standard provides two functions, balanceOfBatch and safeBatchTransferFrom, that make querying multiple balances and transferring multiple tokens simpler and less gas-intensive.

In the spirit of the standard, we’ve also included batch operations in the non-standard functions, such <span class="hljs-keyword">as</span> _mintBatch.
Constructing an ERC1155 Token Contract

We’ll use ERC1155 to track multiple items in our game, which will each have their own unique attributes. We mint all items to the deployer of the <span class="hljs-keyword">contract</span>, which we can later transfer to players. Players are free to keep their tokens or trade them with other people <span class="hljs-keyword">as</span> they see fit, <span class="hljs-keyword">as</span> they would any other asset on the blockchain!

For simplicity we will mint all items in the <span class="hljs-keyword">constructor</span> but you could add minting functionality to the <span class="hljs-keyword">contract</span> to mint on demand to players.
    For an overview of minting mechanisms check out Creating ERC20 Supply.

Here’s what a <span class="hljs-keyword">contract</span> <span class="hljs-keyword">for</span> tokenized items might look like:

// contracts/GameItems.sol
// SPDX-License-Identifier: MIT
<span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.6.0;</span>

<span class="hljs-keyword">import</span> <span class="hljs-string">"@openzeppelin/contracts/token/ERC1155/ERC1155.sol"</span>;

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">GameItems</span> <span class="hljs-keyword">is</span> <span class="hljs-title">ERC1155</span> </span>{
    <span class="hljs-keyword">uint256</span> <span class="hljs-keyword">public</span> <span class="hljs-keyword">constant</span> GOLD <span class="hljs-operator">=</span> <span class="hljs-number">0</span>;
    <span class="hljs-keyword">uint256</span> <span class="hljs-keyword">public</span> <span class="hljs-keyword">constant</span> SILVER <span class="hljs-operator">=</span> <span class="hljs-number">1</span>;
    <span class="hljs-keyword">uint256</span> <span class="hljs-keyword">public</span> <span class="hljs-keyword">constant</span> THORS_HAMMER <span class="hljs-operator">=</span> <span class="hljs-number">2</span>;
    <span class="hljs-keyword">uint256</span> <span class="hljs-keyword">public</span> <span class="hljs-keyword">constant</span> SWORD <span class="hljs-operator">=</span> <span class="hljs-number">3</span>;
    <span class="hljs-keyword">uint256</span> <span class="hljs-keyword">public</span> <span class="hljs-keyword">constant</span> SHIELD <span class="hljs-operator">=</span> <span class="hljs-number">4</span>;

    <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title">ERC1155</span>(<span class="hljs-params"><span class="hljs-string">"https://game.example/api/item/{id}.json"</span></span>) </span>{
        _mint(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>, GOLD, <span class="hljs-number">10</span><span class="hljs-operator">*</span><span class="hljs-operator">*</span><span class="hljs-number">18</span>, <span class="hljs-string">""</span>);
        _mint(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>, SILVER, <span class="hljs-number">10</span><span class="hljs-operator">*</span><span class="hljs-operator">*</span><span class="hljs-number">27</span>, <span class="hljs-string">""</span>);
        _mint(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>, THORS_HAMMER, <span class="hljs-number">1</span>, <span class="hljs-string">""</span>);
        _mint(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>, SWORD, <span class="hljs-number">10</span><span class="hljs-operator">*</span><span class="hljs-operator">*</span><span class="hljs-number">9</span>, <span class="hljs-string">""</span>);
        _mint(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>, SHIELD, <span class="hljs-number">10</span><span class="hljs-operator">*</span><span class="hljs-operator">*</span><span class="hljs-number">9</span>, <span class="hljs-string">""</span>);
    }
}
</code></pre><blockquote>
<p>More about this example https://docs.openzeppelin.com/contracts/3.x/erc1155</p>
</blockquote>
<h2 id="heading-the-future-of-erc-token-standards">The Future of ERC Token Standards</h2>
<p>The various ERCs discussed here are only a sampling of the various tokenization standards that are being developed within the Ethereum network. As the network continues to grow, more and more tokenization standards will be added to satisfy various use cases.</p>
<p>Although the ERC-20 token standard is still widely used, more complex and interoperable tokenization standards are needed in order to address the network's congestion and transaction costs.</p>
]]></content:encoded></item><item><title><![CDATA[How to create a timer in React using setInterval]]></title><description><![CDATA[Ever wanted to create your very own timer that updates on your website every second without needing to refresh the page? Here's a short tutorial on how you can do it. 
What is setInterval?
It's a function that ensures your code are being run every x ...]]></description><link>https://typec.hashnode.dev/how-to-create-a-timer-in-react-using-setinterval</link><guid isPermaLink="true">https://typec.hashnode.dev/how-to-create-a-timer-in-react-using-setinterval</guid><category><![CDATA[React]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[newbie]]></category><dc:creator><![CDATA[TypeC]]></dc:creator><pubDate>Tue, 15 Mar 2022 09:39:11 GMT</pubDate><content:encoded><![CDATA[<p>Ever wanted to create your very own timer that updates on your website every second without needing to refresh the page? Here's a short tutorial on how you can do it. </p>
<h3 id="heading-what-is-setinterval">What is setInterval?</h3>
<p>It's a function that ensures your code are being run every x seconds. Here's an example of how it looks</p>
<pre><code>setInterval(() <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
  console.log(<span class="hljs-string">'Hello World'</span>);
}, <span class="hljs-number">1000</span>); <span class="hljs-comment">// Takes in a value in millisecond</span>
</code></pre><p>Now that you know how setInterval works, let's get started! </p>
<pre><code><span class="hljs-keyword">import</span> { <span class="hljs-title">useEffect</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"react"</span>

<span class="hljs-title">const</span> <span class="hljs-title">App</span> <span class="hljs-operator">=</span> () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
    <span class="hljs-title">const</span> [<span class="hljs-title">time</span>, <span class="hljs-title">setTimer</span>] <span class="hljs-operator">=</span> <span class="hljs-title">useState</span>(<span class="hljs-title"><span class="hljs-keyword">new</span></span> <span class="hljs-title">Date</span>())

    <span class="hljs-title">useEffect</span>(() <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
        <span class="hljs-comment">// This sets a new date every second</span>
        <span class="hljs-title">const</span> <span class="hljs-title">timer</span> <span class="hljs-operator">=</span> <span class="hljs-title">setInterval</span>(() <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
            <span class="hljs-title">setTimer</span>(<span class="hljs-title"><span class="hljs-keyword">new</span></span> <span class="hljs-title">Date</span>())
        }, 1000)

        <span class="hljs-comment">// This will clear the interval when you exit the page to prevent memory leaks</span>
        <span class="hljs-title"><span class="hljs-keyword">return</span></span> () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> <span class="hljs-title">clearInterval</span>(<span class="hljs-title">timer</span>)
    }, [])

    <span class="hljs-title"><span class="hljs-keyword">return</span></span> (
        <span class="hljs-operator">&lt;</span><span class="hljs-title">div</span><span class="hljs-operator">&gt;</span>
             <span class="hljs-operator">&lt;</span><span class="hljs-title">p</span><span class="hljs-operator">&gt;</span>{<span class="hljs-title">time</span>}<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">p</span><span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">div</span><span class="hljs-operator">&gt;</span>
    )
}
</code></pre><h3 id="heading-conclusion">Conclusion</h3>
<p>Now that you've learnt how to create a timer that updates on your website every second without needing to refresh the page, you can start showing off what you've learnt by implementing it on your site. Although this is a really short tutorial, I hope you enjoy it. More tutorials will be coming soon :)</p>
]]></content:encoded></item></channel></rss>