<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bala prakash on Medium]]></title>
        <description><![CDATA[Stories by Bala prakash on Medium]]></description>
        <link>https://medium.com/@reddy.balu515?source=rss-90be45cc4cab------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Bala prakash on Medium</title>
            <link>https://medium.com/@reddy.balu515?source=rss-90be45cc4cab------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 15:55:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@reddy.balu515/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Real-Time Project Involving Stencil JS]]></title>
            <link>https://medium.com/@reddy.balu515/real-time-project-involving-stencil-js-5a60f5311458?source=rss-90be45cc4cab------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a60f5311458</guid>
            <dc:creator><![CDATA[Bala prakash]]></dc:creator>
            <pubDate>Sun, 19 May 2024 18:37:34 GMT</pubDate>
            <atom:updated>2024-05-19T18:37:34.487Z</atom:updated>
            <content:encoded><![CDATA[<p>Question 1: Can you describe a real-time project where you used Stencil JS?<br>Response:</p><p>Project Overview:</p><p>Objective: Develop a library of reusable web components to be used across the e-commerce platform.<br>Tools and Technologies: Stencil JS, , HTML, CSS, Webpack, Jest for testing, and Storybook for documentation.<br>Implementation Steps:</p><p>Requirement Gathering and Planning:</p><p>Collaborated with UI/UX designers and frontend developers to understand the requirements for the components.<br>Identified common elements such as buttons, modals, carousels, and product cards that needed to be developed as reusable components.<br>Component Development:</p><p>Used Stencil JS to create highly efficient, reusable web components. Stencil’s compiler generated standard-compliant web components, ensuring they could be used with any JavaScript framework.<br>Wrote components in to leverage strong typing and ensure code quality.<br>Styled components using CSS and Shadow DOM to encapsulate styles, preventing conflicts with the global styles of the hosting applications.<br>Testing and Quality Assurance:</p><p>Implemented unit tests using Jest to ensure each component functioned correctly.<br>Conducted integration tests to verify that the components worked seamlessly within different parts of the platform.<br>Documentation and Deployment:</p><p>Documented each component using Storybook, providing a visual representation and usage guidelines for developers.<br>Configured Webpack to bundle the components and ensured they were optimized for performance.<br>Deployed the component library to a private npm registry, making it easy for other developers within the organization to use the components in their projects.<br>Integration and Feedback:</p><p>Integrated the components into various parts of the e-commerce platform.<br>Gathered feedback from the development team and end-users, making iterative improvements to the components based on their input.<br>Outcome:</p><p>The use of Stencil JS significantly improved the development workflow by providing a consistent, reusable set of components.<br>Reduced the time needed to develop new features, as developers could quickly assemble interfaces using the pre-built components.<br>Enhanced the overall user experience with a consistent look and feel across the platform.<br>This project demonstrated the power of Stencil JS in creating scalable and maintainable web components that can be reused across different parts of an application, leading to increased efficiency and consistency.</p><p>Question 2: How did you handle state management in your Stencil JS components?<br>Response:</p><p>In the project, I handled state management within Stencil JS components by leveraging Stencil’s built-in state management features and, where necessary, integrating external state management solutions.</p><p>Approach:</p><p>Internal State Management:</p><p>Used Stencil’s <a href="http://twitter.com/State">@State</a> decorator to manage the internal state of components. This allowed me to create reactive properties that automatically re-render the component when the state changes.<br>Example:<br>Context API:</p><pre>@Component({<br> tag: &#39;my-component&#39;,<br> styleUrl: &#39;my-component.css&#39;,<br> shadow: true<br>})<br>export class MyComponent {<br> @State() count: number = 0;<br>increment() {<br> this.count += 1;<br> }<br>render() {<br> return (<br> &lt;div&gt;<br> &lt;p&gt;Count: {this.count}&lt;/p&gt;<br> &lt;button onClick={() =&gt; this.increment()}&gt;Increment&lt;/button&gt;<br> &lt;/div&gt;<br> );<br> }<br>}</pre><p>Utilized Stencil’s Context API to share state between deeply nested components without passing props down manually at every level. This was particularly useful for managing global state, such as user authentication status or theme settings.<br>Example:</p><p>// context.ts</p><pre>import { createContext } from &#39;@stencil/core&#39;;<br>export const MyContext = createContext({ theme: &#39;light&#39; });<br>// parent-component.tsx<br>import { MyContext } from &#39;./context&#39;;<br>@Component({<br> tag: &#39;parent-component&#39;,<br> styleUrl: &#39;parent-component.css&#39;,<br> shadow: true<br>})<br>export class ParentComponent {<br> render() {<br> return (<br> &lt;my-context.Provider value={{ theme: &#39;dark&#39; }}&gt;<br> &lt;child-component&gt;&lt;/child-component&gt;<br> &lt;/my-context.Provider&gt;<br> );<br> }<br>}</pre><p>// child-component.tsx</p><pre>import { MyContext } from &#39;./context&#39;;<br>@Component({<br> tag: &#39;child-component&#39;,<br> styleUrl: &#39;child-component.css&#39;,<br> shadow: true<br>})<br>export class ChildComponent {<br> render() {<br> return (<br> &lt;MyContext.Consumer&gt;<br> {({ theme }) =&gt; (<br> &lt;div class={`theme-${theme}`}&gt;<br> &lt;p&gt;Current theme: {theme}&lt;/p&gt;<br> &lt;/div&gt;<br> )}<br> &lt;/MyContext.Consumer&gt;<br> );<br> }<br>}</pre><p>External State Management:</p><p>For more complex state management needs, integrated external libraries such as Redux or MobX. These libraries provided robust state management capabilities and could be used seamlessly with Stencil JS components.<br>By effectively managing state within Stencil JS components, I ensured that the components were both reactive and maintainable, allowing for a seamless user experience and easy integration across the platform.</p><p><strong>explaining with examples?</strong><br><br>Example 1: Creating a Reusable Counter Component<br>Step 1: Set Up the Stencil Project<br>First, set up a new Stencil project if you haven’t already:</p><blockquote>npm init stencil<br>Follow the prompts to create your project.</blockquote><p>Step 2: Create the Counter Component<br>Create a new component called my-counter:</p><p>// src/components/my-counter/my-counter.tsx</p><pre>import { Component, State, h } from &#39;@stencil/core&#39;;<br>@Component({<br> tag: &#39;my-counter&#39;,<br> styleUrl: &#39;my-counter.css&#39;,<br> shadow: true<br>})<br>export class MyCounter {<br> @State() count: number = 0;<br>increment = () =&gt; {<br> this.count += 1;<br> };<br>render() {<br> return (<br> &lt;div&gt;<br> &lt;p&gt;Count: {this.count}&lt;/p&gt;<br> &lt;button onClick={this.increment}&gt;Increment&lt;/button&gt;<br> &lt;/div&gt;<br> );<br> }<br>}</pre><p>Step 3: Style the Component<br>Add some basic styles for the component:</p><p>/* src/components/my-counter/my-counter.css */</p><pre>div {<br> text-align: center;<br> font-family: Arial, sans-serif;<br>}<br>button {<br> padding: 8px 16px;<br> margin-top: 10px;<br>}</pre><p>Step 4: Use the Component<br>Now, use the my-counter component in your application:</p><pre>&lt;! - src/index.html →<br>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br> &lt;meta charset=&quot;UTF-8&quot;&gt;<br> &lt;title&gt;Stencil Counter&lt;/title&gt;<br> &lt;script type=&quot;module&quot; src=&quot;/build/myapp.esm.js&quot;&gt;&lt;/script&gt;<br> &lt;script nomodule src=&quot;/build/myapp.js&quot;&gt;&lt;/script&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br> &lt;my-counter&gt;&lt;/my-counter&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;<br>Example 2: Using Context API for Theme Management<br>Step 1: Create a Context<br>Define a context for theme management:<br>// src/global/app-context.ts<br>import { createContext } from &#39;@stencil/core&#39;;<br>export const AppContext = createContext({<br> theme: &#39;light&#39;,<br> toggleTheme: () =&gt; {}<br>});</pre><p>Step 2: Create the ThemeProvider Component<br>Create a provider component to manage and provide the theme context:</p><p>// src/components/theme-provider/theme-provider.tsx</p><pre>import { Component, State, h } from &#39;@stencil/core&#39;;<br>import { AppContext } from &#39;../../global/app-context&#39;;<br>@Component({<br> tag: &#39;theme-provider&#39;,<br> shadow: true<br>})<br>export class ThemeProvider {<br> @State() theme: &#39;light&#39; | &#39;dark&#39; = &#39;light&#39;;<br>toggleTheme = () =&gt; {<br> this.theme = this.theme === &#39;light&#39; ? &#39;dark&#39; : &#39;light&#39;;<br> };<br>render() {<br> return (<br> &lt;AppContext.Provider value={{ theme: this.theme, toggleTheme: this.toggleTheme }}&gt;<br> &lt;slot /&gt;<br> &lt;/AppContext.Provider&gt;<br> );<br> }<br>}</pre><p>Step 3: Create a Child Component to Consume the Theme<br>Create a component that consumes the theme context:</p><p>// src/components/theme-consumer/theme-consumer.tsx</p><pre>import { Component, h } from &#39;@stencil/core&#39;;<br>import { AppContext } from &#39;../../global/app-context&#39;;<br>@Component({<br> tag: &#39;theme-consumer&#39;,<br> shadow: true<br>})<br>export class ThemeConsumer {<br> render() {<br> return (<br> &lt;AppContext.Consumer&gt;<br> {({ theme, toggleTheme }) =&gt; (<br> &lt;div class={`theme-${theme}`}&gt;<br> &lt;p&gt;Current theme: {theme}&lt;/p&gt;<br> &lt;button onClick={toggleTheme}&gt;Toggle Theme&lt;/button&gt;<br> &lt;/div&gt;<br> )}<br> &lt;/AppContext.Consumer&gt;<br> );<br> }<br>}</pre><p>Step 4: Style the Components<br>Add styles for the theme:</p><p>/* src/components/theme-consumer/theme-consumer.css */</p><pre>.theme-light {<br> background-color: white;<br> color: black;<br>}<br>.theme-dark {<br> background-color: black;<br> color: white;<br>}</pre><p>Step 5: Use the Components in the Application<br>Integrate the provider and consumer in your application:</p><pre>&lt;! - src/index.html →<br>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br> &lt;meta charset=&quot;UTF-8&quot;&gt;<br> &lt;title&gt;Stencil Theme Example&lt;/title&gt;<br> &lt;script type=&quot;module&quot; src=&quot;/build/myapp.esm.js&quot;&gt;&lt;/script&gt;<br> &lt;script nomodule src=&quot;/build/myapp.js&quot;&gt;&lt;/script&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br> &lt;theme-provider&gt;<br> &lt;theme-consumer&gt;&lt;/theme-consumer&gt;<br> &lt;/theme-provider&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Example 3: Integrating Stencil Components with External State Management (Redux)<br>Step 1: Set Up Redux<br>Install Redux and related packages:</p><blockquote>npm install <a href="http://twitter.com/reduxjs/toolkit">@reduxjs/toolkit</a> react-redux<br>Step 2: Configure Redux Store<br>Create a Redux store and slice for managing state:</blockquote><p>// src/global/store.ts</p><pre>import { configureStore, createSlice } from &#39;@reduxjs/toolkit&#39;;<br>const counterSlice = createSlice({<br> name: &#39;counter&#39;,<br> initialState: { count: 0 },<br> reducers: {<br> increment: state =&gt; {<br> state.count += 1;<br> }<br> }<br>});<br>export const { increment } = counterSlice.actions;<br>export const store = configureStore({<br> reducer: {<br> counter: counterSlice.reducer<br> }<br>});</pre><p>Step 3: Create a Redux-Connected Component<br>Create a Stencil component that connects to the Redux store:</p><p>// src/components/redux-counter/redux-counter.tsx</p><pre>import { Component, h } from &#39;@stencil/core&#39;;<br>import { store, increment } from &#39;../../global/store&#39;;<br>import { connect } from &#39;react-redux&#39;;<br>@Component({<br> tag: &#39;redux-counter&#39;,<br> shadow: true<br>})<br>export class ReduxCounter {<br> private unsubscribe: () =&gt; void;<br> private state = store.getState();<br>connectedCallback() {<br> this.unsubscribe = store.subscribe(() =&gt; {<br> this.state = store.getState();<br> });<br> }<br>disconnectedCallback() {<br> this.unsubscribe();<br> }<br>render() {<br> return (<br> &lt;div&gt;<br> &lt;p&gt;Count: {this.state.counter.count}&lt;/p&gt;<br> &lt;button onClick={() =&gt; store.dispatch(increment())}&gt;Increment&lt;/button&gt;<br> &lt;/div&gt;<br> );<br> }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a60f5311458" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To fetch records from an API in Stencil JS]]></title>
            <link>https://medium.com/@reddy.balu515/how-to-fetch-records-from-an-api-in-stencil-js-076ca87c6105?source=rss-90be45cc4cab------2</link>
            <guid isPermaLink="false">https://medium.com/p/076ca87c6105</guid>
            <dc:creator><![CDATA[Bala prakash]]></dc:creator>
            <pubDate>Fri, 17 May 2024 20:26:16 GMT</pubDate>
            <atom:updated>2024-05-17T20:26:56.582Z</atom:updated>
            <content:encoded><![CDATA[<p>To fetch records from an API in StencilJS, you need to utilize the lifecycle methods provided by StencilJS to make your API calls. Typically, you would use the componentWillLoad or componentDidLoad lifecycle methods for such tasks.</p><p>Here’s a step-by-step guide on how to implement this:</p><ol><li><strong>Create a new StencilJS component</strong>: Use the Stencil CLI to generate a new component.</li></ol><ul><li>npx stencil generate component-name</li></ul><ol><li><strong>Modify the component to fetch records from an API</strong>: Add your API call logic within the appropriate lifecycle method. Here’s an example implementation</li></ol><pre>import { Component, State, h } from &#39;@stencil/core&#39;;<br>@Component({<br>  tag: &#39;my-component&#39;,<br>  styleUrl: &#39;my-component.css&#39;,<br>  shadow: true,<br>})<br>export class MyComponent {<br>  @State() records: any[] = [];<br>  // Lifecycle method that runs before the component is loaded<br>  componentWillLoad() {<br>    this.fetchRecords();<br>  }<br>  // Function to fetch records from the API<br>  async fetchRecords() {<br>    try {<br>      const response = await fetch(&#39;https://api.example.com/records?limit=1000&#39;);<br>      const data = await response.json();<br>      this.records = data;<br>    } catch (error) {<br>      console.error(&#39;Error fetching records:&#39;, error);<br>    }<br>  }<br>  render() {<br>    return (<br>      &lt;div&gt;<br>        &lt;h1&gt;Records&lt;/h1&gt;<br>        &lt;ul&gt;<br>          {this.records.map(record =&gt; (<br>            &lt;li&gt;{record.name}&lt;/li&gt;<br>          ))}<br>        &lt;/ul&gt;<br>      &lt;/div&gt;<br>    );<br>  }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=076ca87c6105" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stencil Js Interview Questions]]></title>
            <link>https://medium.com/@reddy.balu515/stencil-js-interview-questions-544c03c61249?source=rss-90be45cc4cab------2</link>
            <guid isPermaLink="false">https://medium.com/p/544c03c61249</guid>
            <category><![CDATA[stencil]]></category>
            <dc:creator><![CDATA[Bala prakash]]></dc:creator>
            <pubDate>Fri, 17 May 2024 03:08:58 GMT</pubDate>
            <atom:updated>2024-05-17T03:08:58.565Z</atom:updated>
            <content:encoded><![CDATA[<h4>1. What is Stencil JS, and why was it created?</h4><p><strong>Example Answer:</strong> Stencil JS is a compiler for building reusable, scalable web components and Progressive Web Apps (PWAs) using standard web technologies like HTML, CSS, and JavaScript. It was created by the Ionic team to solve the challenges of building modern, highly interactive web applications that need to work across different platforms and devices. Stencil JS combines the best concepts of frameworks like Angular and React, such as reactive data-binding and declarative rendering, but aims to produce standard-compliant web components that work seamlessly in any JavaScript framework or even without one.</p><h4>2. How does Stencil JS differ from other JavaScript frameworks like React or Angular?</h4><p><strong>Example Answer:</strong> Stencil JS differs from frameworks like React or Angular in that it is not a framework itself, but a compiler that generates standard web components. These components are framework-agnostic and can be used in any web application regardless of the underlying framework. Unlike React or Angular, which require their runtime libraries, Stencil JS components are lightweight and have minimal dependencies, leading to faster load times and better performance. Stencil also focuses on leveraging the web platform’s native capabilities rather than abstracting them away, promoting reusability and interoperability.</p><h4>3. Explain the role of decorators in Stencil JS and provide examples.</h4><p><strong>Example Answer:</strong> Decorators in Stencil JS are used to add metadata to classes, properties, and methods, enabling the framework to understand how to process them. The most common decorators in Stencil are @Component, @Prop, @State, and @Listen.</p><ul><li>@Component: Defines a Stencil component.</li><li>@Prop: Declares a property that can be passed from a parent component.</li><li>@State: Declares a reactive state variable.</li><li>@Listen: Attaches event listeners to DOM events.</li></ul><p><strong>Examples</strong></p><pre>import { Component, Prop, State, h } from &#39;@stencil/core&#39;;<br>@Component({<br>  tag: &#39;my-component&#39;,<br>  styleUrl: &#39;my-component.css&#39;,<br>  shadow: true<br>})<br>export class MyComponent {<br>  @Prop() name: string;<br>  @State() count: number = 0;<br>@Listen(&#39;click&#39;, { capture: true })<br>  handleClick() {<br>    this.count++;<br>  }<br>  render() {<br>    return (<br>      &lt;div&gt;<br>        &lt;p&gt;Hello, {this.name}! You clicked {this.count} times.&lt;/p&gt;<br>        &lt;button&gt;Click me&lt;/button&gt;<br>      &lt;/div&gt;<br>    );<br>  }<br>}</pre><h4>4. What is Shadow DOM and how does Stencil JS utilize it?</h4><p><strong>Example Answer:</strong> Shadow DOM is a web standard that encapsulates a component’s internal DOM structure, styles, and behavior, preventing them from affecting or being affected by the rest of the document’s DOM. This encapsulation provides better modularity and prevents style conflicts.</p><p>Stencil JS utilizes Shadow DOM to ensure that the styles and scripts of a component are scoped to that component, making them truly self-contained and reusable. When defining a component with Stencil, you can enable Shadow DOM by setting the shadow property to true in the @Component decorator.</p><p><strong>Example:</strong></p><pre>@Component({<br>  tag: &#39;my-shadow-component&#39;,<br>  styleUrl: &#39;my-shadow-component.css&#39;,<br>  shadow: true<br>})<br>export class MyShadowComponent {<br>  render() {<br>    return (<br>      &lt;div&gt;<br>        &lt;p&gt;This component uses Shadow DOM!&lt;/p&gt;<br>      &lt;/div&gt;<br>    );<br>  }<br>}</pre><h4>5. How does Stencil JS handle state management within a component?</h4><p><strong>Example Answer:</strong> Stencil JS handles state management within a component using the @State decorator. State variables are reactive, meaning that changes to these variables automatically trigger a re-render of the component.</p><p><strong>Example:</strong></p><pre>@Component({<br>  tag: &#39;my-state-component&#39;,<br>  styleUrl: &#39;my-state-component.css&#39;,<br>  shadow: true<br>})<br>export class MyStateComponent {<br>  @State() count: number = 0;<br>increment() {<br>    this.count++;<br>  }<br>  render() {<br>    return (<br>      &lt;div&gt;<br>        &lt;p&gt;Current count: {this.count}&lt;/p&gt;<br>        &lt;button onClick={() =&gt; this.increment()}&gt;Increment&lt;/button&gt;<br>      &lt;/div&gt;<br>    );<br>  }<br>}</pre><h4>6. Explain the concept of props in Stencil JS. How do you define and use them?</h4><p><strong>Example Answer:</strong> Props in Stencil JS are similar to properties in other frameworks and are used to pass data from a parent component to a child component. Props are defined using the @Prop decorator.</p><p><strong>Example:</strong></p><pre>@Component({<br>  tag: &#39;my-prop-component&#39;,<br>  styleUrl: &#39;my-prop-component.css&#39;,<br>  shadow: true<br>})<br>export class MyPropComponent {<br>  @Prop() message: string;<br>render() {<br>    return (<br>      &lt;div&gt;<br>        &lt;p&gt;{this.message}&lt;/p&gt;<br>      &lt;/div&gt;<br>    );<br>  }<br>}</pre><p>To use this component and pass a prop:</p><pre>&lt;my-prop-component message=&quot;Hello, Stencil!&quot;&gt;&lt;/my-prop-component&gt;</pre><h4>7. What is lazy loading in Stencil JS, and how does it improve performance?</h4><p><strong>Example Answer:</strong> Lazy loading in Stencil JS is a technique that delays the loading of non-essential resources at page load time. Instead of loading all the components and resources upfront, only the necessary ones are loaded initially, and the rest are loaded as needed. This improves the performance and reduces the initial load time of the application.</p><p>Stencil JS automatically handles lazy loading of components by splitting the JavaScript bundles and loading them on demand. This is achieved through the use of the Stencil compiler, which analyzes the dependencies and creates optimized bundles for efficient loading.</p><p><strong>Example:</strong> When you build your Stencil project, the compiler generates multiple JavaScript files, ensuring that components are loaded only when they are used, enhancing the overall performance of your web application.</p><h4>8. How does Stencil JS enable server-side rendering (SSR)?</h4><p><strong>Example Answer:</strong> Stencil JS supports server-side rendering (SSR) to improve the performance and SEO of web applications. SSR is the process of rendering the initial HTML of a web page on the server before sending it to the client. This allows the browser to display the content faster and improves the user experience, especially on slower devices or networks.</p><p>Stencil provides a built-in SSR feature that can be enabled using the Stencil CLI. The hydrateApp function can be used to pre-render the components on the server.</p><p><strong>Example:</strong></p><pre>import { renderToString } from &#39;@stencil/core/hydrate&#39;;<br>import { readFileSync } from &#39;fs&#39;;<br>const html = readFileSync(&#39;index.html&#39;, &#39;utf8&#39;);<br>renderToString(html, {<br>  url: &#39;https://example.com&#39;,<br>  serializeToHtml: true<br>}).then(result =&gt; {<br>  console.log(result.html);<br>});</pre><p>This example shows how to use the renderToString function to pre-render an HTML file. The url option specifies the URL of the page to be rendered, and the serializeToHtml option indicates whether to serialize the result to HTML.</p><h4>9. Describe how you would handle routing in a Stencil JS application.</h4><p><strong>Example Answer:</strong> Stencil JS does not come with a built-in router, but it is compatible with various routing libraries like Stencil Router, a lightweight router specifically designed for Stencil.</p><p>To handle routing in a Stencil JS application, you can use the Stencil Router by installing it and defining routes in your main component.</p><p><strong>Example:</strong> First, install the Stencil Router:</p><pre>npm install @stencil/router</pre><p>Then, set up routing in your main component:</p><pre>import { Component, h } from &#39;@stencil/core&#39;;<br>import { Router, Route } from &#39;@stencil/router&#39;;<br>@Component({<br>  tag: &#39;app-root&#39;,<br>  styleUrl: &#39;app-root.css&#39;,<br>  shadow: true<br>})<br>export class AppRoot {<br>  render() {<br>    return (<br>      &lt;div&gt;<br>        &lt;header&gt;<br>          &lt;nav&gt;<br>            &lt;stencil-route-link url=&quot;/&quot;&gt;Home&lt;/stencil-route-link&gt;<br>            &lt;stencil-route-link url=&quot;/about&quot;&gt;About&lt;/stencil-route-link&gt;<br>          &lt;/nav&gt;<br>        &lt;/header&gt;<br>        &lt;main&gt;<br>          &lt;Router&gt;<br>            &lt;Route url=&quot;/&quot; component=&quot;app-home&quot; /&gt;<br>            &lt;Route url=&quot;/about&quot; component=&quot;app-about&quot; /&gt;<br>          &lt;/Router&gt;<br>        &lt;/main&gt;<br>      &lt;/div&gt;<br>    );<br>  }<br>}</pre><p>Here, the Router component is used to define the routes, and stencil-route-link is used to create navigation links. The Route component maps URLs to specific components.</p><h4>10. What are some best practices for developing with Stencil JS?</h4><p><strong>Example Answer:</strong> Some best practices for developing with Stencil JS include:</p><ol><li><strong>Component Reusability:</strong> Design components to be reusable and framework-agnostic. Avoid tight coupling with specific frameworks or libraries.</li><li><strong>Shadow DOM:</strong> Use Shadow DOM to encapsulate component styles and prevent style conflicts.</li><li><strong>Performance Optimization:</strong> Leverage lazy loading and minimize the component footprint to improve performance.</li><li><strong>State Management:</strong> Use @State and @Prop appropriately to manage the internal state and pass data between components.</li><li><strong>Testing:</strong> Write unit and end-to-end tests for components to ensure they work as expected.</li><li><strong>Accessibility:</strong> Ensure components are accessible by following ARIA guidelines and testing with screen readers.</li><li><strong>Documentation:</strong> Document components, properties, and events clearly to make it easier for other developers to use and understand them.</li><li><strong>Version Control:</strong> Use version control systems like Git to manage your codebase and track changes.</li></ol><p>By following these best practices, you can create efficient, maintainable, and scalable web components with Stencil JS.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=544c03c61249" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL Interview questions]]></title>
            <link>https://medium.com/@reddy.balu515/sql-interview-questions-269f32cf6714?source=rss-90be45cc4cab------2</link>
            <guid isPermaLink="false">https://medium.com/p/269f32cf6714</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[sql-interview-questions]]></category>
            <dc:creator><![CDATA[Bala prakash]]></dc:creator>
            <pubDate>Sun, 07 Jan 2024 09:33:18 GMT</pubDate>
            <atom:updated>2024-01-07T09:33:18.904Z</atom:updated>
            <content:encoded><![CDATA[<ol><li>What are the commonly used date functions and explain about every Date function and uses of them?</li></ol><p>GETDATE(): Returns the current date and time.</p><pre>SELECT GETDATE();<br></pre><p>SYSDATETIME(): Returns the current date and time with greater precision compared to GETDATE().</p><pre>SELECT SYSDATETIME();</pre><p>DATEPART(): Extracts a specific part (year, month, day, etc.) of a date.</p><pre>SELECT DATEPART(YEAR, GETDATE()) AS Year;</pre><p>DATEDIFF(): Calculates the difference between two dates.</p><pre>SELECT DATEDIFF(DAY, &#39;2022–01–01&#39;, &#39;2022–01–10&#39;) AS DateDifference;</pre><p>DATEADD(): Adds or subtracts a specified time interval from a date.</p><pre>SELECT DATEADD(MONTH, 3, GETDATE()) AS ThreeMonthsLater;</pre><p>CONVERT(): Converts a date/time value to a different format.</p><pre>SELECT CONVERT(VARCHAR, GETDATE(), 103) AS DateFormatted;</pre><p>FORMAT(): Formats a date/time value using a specified format pattern.</p><pre>SELECT FORMAT(GETDATE(), &#39;yyyy-MM-dd HH:mm:ss&#39;) AS FormattedDate;</pre><p>CAST() and CONVERT(): Converts one data type to another, useful for converting strings to dates or vice versa.</p><pre>SELECT CAST(&#39;2022–01–01&#39; AS DATE) AS DateConverted;</pre><p>2. What is the sequence of the clauses in one statement?</p><p>The sequence of clauses in a SQL statement can vary depending on the type of SQL statement you are using. However, I’ll provide a general overview of the sequence of clauses commonly found in SELECT statements, which are used to retrieve data from a database table. Other SQL statements, like UPDATE, INSERT, and DELETE, have different clauses and sequencing.</p><p>Here is the typical sequence of clauses in a SELECT statement:</p><p>SELECT: Specifies the columns or expressions to retrieve.</p><pre>SELECT column1, column2, …</pre><p>FROM: Specifies the table or tables from which to retrieve the data.</p><pre>FROM tablename</pre><p>WHERE: Filters the rows returned based on a specified condition.</p><p><strong>WHERE condition</strong><br>GROUP BY: Groups the result set by one or more columns.</p><pre>GROUP BY column1, column2, …</pre><p>HAVING: Filters the grouped results based on a specified condition.</p><blockquote><strong>HAVING condition</strong><br>ORDER BY: Sorts the result set by one or more columns.</blockquote><blockquote>ORDER BY column1 [ASC|DESC], column2 [ASC|DESC], …<br>LIMIT (or FETCH FIRST): Specifies the number of rows to return, useful for pagination or limiting the result set.</blockquote><p>LIMIT n; — Standard SQL<br> — or<br>FETCH FIRST n ROWS ONLY; — SQL Server and some other databases<br>This is a basic sequence, and not all clauses are required in every SELECT statement. For example, you may have a simple SELECT statement with just SELECT and FROM clauses, or you may include all clauses for more complex queries.</p><p>Keep in mind that the specific SQL dialect and the database system you are using might have variations or additional clauses</p><p>3. What is the difference between WHERE and Having?</p><p>WHERE Clause:</p><p>Used with: SELECT, UPDATE, DELETE statements.<br>Purpose: Filters rows before they are grouped and aggregated (if any).<br>Typically used for: Filtering individual rows based on conditions.<br>Example:</p><pre>SELECT FirstName, LastName, Salary<br>FROM Employees<br>WHERE Salary &gt; 55000;<br>In this example, the WHERE clause filters out rows where the salary is less than or equal to 55000 before the results are displayed.</pre><p>HAVING Clause:</p><p>Used with: SELECT statements with GROUP BY clause.<br>Purpose: Filters groups of rows after they have been formed by the GROUP BY clause and aggregated (if any).<br>Typically used for: Filtering aggregated data based on conditions.<br>Example:</p><pre>SELECT COUNT(*), Salary<br>FROM Employees<br>GROUP BY Salary<br>HAVING COUNT(*) &gt; 1;</pre><p>In this example, the HAVING clause filters out groups where the count of rows in each group is not greater than 1.</p><p>In summary, the main difference is in when they are applied:</p><p>WHERE is used to filter rows before any grouping or aggregation occurs.<br>HAVING is used to filter the results after they have been grouped and aggregated.<br>It’s important to note that you can use WHERE without GROUP BY, but you can only use HAVING with GROUP BY. Additionally, conditions in the HAVING clause typically involve aggregated values (e.g., using aggregate functions like COUNT, SUM, etc.).</p><ol><li>Req: Create a table to store Sales Transactions, name it Sales, with the following columns, TID, CID, Price, Quantity?</li></ol><pre>Create Table Sales (<br>TID INT PRIMARY KEY,<br>CID INT,<br>Price Decimal(10,2),<br>Quantity INT<br>);</pre><p>2. Req: Insert the below value into Sales table?<br>- insert into Sales values<br> (1, ‘C1’, 1.50, 10)<br> , (2, ‘C2’, 2.25, 5)<br> , (3, ‘C3’, 10, 2)<br> , (4, ‘C4’, 4, 20)<br> , (5, ‘C1’, 25, 1)<br> , (6, ‘C5’, 5.10, 4)<br> , (7, ‘C3’, 0.50, 10)<br> , (8, ‘C1’, 100, 1)<br> , (9, ‘C6’, 0.75, 20)<br> , (10, ‘C10’, 0.95, 15)<br> , (11, ‘C6’, 16, 3)<br> , (12, ‘C7’, 2.25, 7)<br> , (13, ‘C5’, 25, 1)<br> , (14, ‘C10’, .55, 12)<br> , (15, ‘C9’, 1.25, 15)<br> , (16, ‘C2’, 100, 1)<br> , (17, ‘C6’, 50, 2)<br> , (18, ‘C7’, 25, 1)<br> , (19, ‘C8’, 70, 4)<br> , (20, ‘C10’, 35, 6)<br> , (21, ‘C8’, 20, 8)<br> , (22, ‘C10’, 20, 1) ;</p><pre>Insert into Sales(TID,CID,Price,Quantity)<br>VALUES (1, &#39;C1&#39;, 1.50, 10)<br> , (2, &#39;C2&#39;, 2.25, 5)<br> , (3, &#39;C3&#39;, 10, 2)<br> , (4, &#39;C4&#39;, 4, 20)<br> , (5, &#39;C1&#39;, 25, 1)<br> , (6, &#39;C5&#39;, 5.10, 4)<br> , (7, &#39;C3&#39;, 0.50, 10)<br> , (8, &#39;C1&#39;, 100, 1)<br> , (9, &#39;C6&#39;, 0.75, 20)<br> , (10, &#39;C10&#39;, 0.95, 15)<br> , (11, &#39;C6&#39;, 16, 3)<br> , (12, &#39;C7&#39;, 2.25, 7)<br> , (13, &#39;C5&#39;, 25, 1)<br> , (14, &#39;C10&#39;, .55, 12)<br> , (15, &#39;C9&#39;, 1.25, 15)<br> , (16, &#39;C2&#39;, 100, 1)<br> , (17, &#39;C6&#39;, 50, 2)<br> , (18, &#39;C7&#39;, 25, 1)<br> , (19, &#39;C8&#39;, 70, 4)<br> , (20, &#39;C10&#39;, 35, 6)<br> , (21, &#39;C8&#39;, 20, 8)<br> , (22, &#39;C10&#39;, 20, 1);</pre><p>3. Req: Print Total Quantity from Sales table?</p><pre>select SUM(Quantity) as TotalQuantity from Sales;<br>Answer:<br>TotalQuantity  <br>149</pre><p>4. Req: Print Average Price?</p><pre>Select SUM(Price) as AveragePrice From Sales;<br>Answer:<br>AveragePrice<br>515.10</pre><p>5. Req: Print Total quantity, average price from sales table?</p><pre>select SUM(Quantity) as TotalQuantity,AVG(Price) as AveragePrice From Sales;<br>TotalQuantity  AveragePrice<br>149           23.413636</pre><p>6. Req: Print TID, CID, Quantity from sales table, and assign / rename TID as TransactionID, CID as CustomerID in the resultset?</p><pre>EXEC sp_rename &#39;Sales.CID&#39;, &#39;CustomerID&#39;,&#39;COLUMN&#39;;<br>EXEC sp_rename &#39;Sales.TID&#39;, &#39;TransactionID&#39;, &#39;COLUMN&#39;;<br><br>select TransactionID,CustomerID,Price,Quantity From  Sales;<br>Answer:<br>TransactionID CustomerID Price Quantity<br>1 C1 1.50 10<br>2 C2 2.25 5<br>3 C3 10.00 2<br>4 C4 4.00 20<br>5 C1 25.00 1<br>6 C5 5.10 4<br>7 C3 0.50 10<br>8 C1 100.00 1<br>9 C6 0.75 20<br>10 C10 0.95 15<br>11 C6 16.00 3<br>12 C7 2.25 7<br>13 C5 25.00 1<br>14 C10 0.55 12<br>15 C9 1.25 15<br>16 C2 100.00 1<br>17 C6 50.00 2<br>18 C7 25.00 1<br>19 C8 70.00 4<br>20 C10 35.00 6<br>21 C8 20.00 8<br>22 C10 20.00 1</pre><p>7. Req: Print total quantity by customer ID from sales table?</p><pre>select CustomerID,SUM(Quantity) as TotalQuantity From Sales group by CustomerID;<br>Result<br>CustomerID  TotalQuantity<br>C1 12<br>C10 34<br>C2 6<br>C3 12<br>C4 20<br>C5 5<br>C6 25<br>C7 8<br>C8 12<br>C9 15</pre><p>9. Req: Print Average quantity by customer ID from sales table?</p><pre>select CustomerID, AVG(Quantity) as AverageQuantity From Sales group by CustomerID;<br>CustomerID  AverageQuantity<br>C1 4<br>C10 8<br>C2 3<br>C3 6<br>C4 20<br>C5 2<br>C6 8<br>C7 4<br>C8 6<br>C9 15</pre><p>10. Req: Print Maximun Price, Total Price by CID from sales table?</p><pre>select CustomerID,MAX(Price) as MaxPrice,SUM(Price) as TotalPrice From Sales group by CustomerID;<br>CustomerID MaxPrice TotalPrice<br>C1 100.00 126.50<br>C10 35.00 56.50<br>C2 100.00 102.25<br>C3 10.00 10.50<br>C4 4.00 4.00<br>C5 25.00 30.10<br>C6 50.00 66.75<br>C7 25.00 27.25<br>C8 70.00 90.00<br>C9 1.25 1.25</pre><p>11. Req: Print Total Quantity, Total Price by CID from sales table, and filter the result set to show only the customers, whose total quantity is more than 15?</p><pre><br>select CustomerID, SUM(Quantity) as TotalQuantity,SUM(Price) as TotalPrice From Sales<br>group by CustomerID <br>Having SUM(Quantity) &gt;15;<br>CustomerID   TotalQuantity TotalPrice<br>C10 34 56.50<br>C4 20 4.00<br>C6 25 66.75</pre><p>13. Req: Print Total Price, Total Quantity by CID from sales table?</p><pre>select CustomerID, SUM(Price) as TotalPrice, SUM(Quantity) as TotalQuantity From Sales<br>group by CustomerID; <br>CustomerID  TotalPrice TotalQuantity<br>C1 126.50 12<br>C10 56.50 34<br>C2 102.25 6<br>C3 10.50 12<br>C4 4.00 20<br>C5 30.10 5<br>C6 66.75 25<br>C7 27.25 8<br>C8 90.00 12<br>C9 1.25 15</pre><p>14. Req: Print Total Price, Total Quantity by CID from sales table, filter the result set to show data for CID C1 ?</p><pre>select CustomerID, SUM(Price) as TotalPrice, SUM(Quantity) as TotalQuantity From Sales <br>Where CustomerID = &#39;C1&#39;<br>group by CustomerID; <br>CustomerID  TotalPrice TotalQuantity<br>C1 126.50 12</pre><p>15. Req: write a statement to print sales, quanity, tid for transaction id 5?</p><pre>select Price as sales,Quantity,transactionid from sales<br>where transactionid = 5;<br><br>sales Quantity transactionid<br>25.00 1 5</pre><p>16. Req: Print total sales, total profit by CID from sales table, filter the data to print data for the following CID’s: C1, C2, C3, C4? Write statement in 2 different ways…</p><pre>using common table expression CTE<br>with SalesData as (<br>select<br>CustomerID,<br>SUM(Price * Quantity) as TotalSales,<br>NULL as TotalProfit<br>From Sales<br>where CustomerID IN(&#39;C1&#39;,&#39;C2&#39;,&#39;C3&#39;,&#39;C4&#39;)<br>Group By CustomerID<br>)<br>Select * from SalesData;<br><br> Totalsales  totalprofit<br>C1 140.00 NULL<br>C2 111.25 NULL<br>C3 25.00 NULL<br>C4 80.00 NULL<br><br>  Using Sub queries::<br><br> SELECT<br>    CustomerID,<br>    SUM(Price * Quantity) AS TotalSales,<br>    NULL AS TotalProfit<br>FROM Sales<br>WHERE CustomerID IN (&#39;C1&#39;, &#39;C2&#39;, &#39;C3&#39;, &#39;C4&#39;)<br>GROUP BY CustomerID;</pre><p>17. Req: Print total price, total quantity by cid, filter the data to show the following cid’s: c2, c6, c7, c8 and c10 and filter this data based on total price, total price must more than 20?</p><pre>select CustomerID, SUM(Price) as TotalPrice,SUM(Quantity) as TotalQuantity<br>From Sales<br>where CustomerID IN (&#39;C6&#39;, &#39;C2&#39;, &#39;C7&#39;, &#39;C8&#39;,&#39;C10&#39;)<br>Group By CustomerID<br>HAVING SUM(Price) &gt; 20;<br><br>CustomerID TotalPrice TotalQuantity<br>C10 56.50 34<br>C2 102.25 6<br>C6 66.75 25<br>C7 27.25 8<br>C8 90.00 12</pre><p>18. Req: Print total price by CID, and sort the result set in the desc order by total price?</p><pre>select CustomerID, SUM(Price) as TotalPrice<br>From Sales<br><br>Group By CustomerID<br>Order by SUM(Price) desc;<br>CustomerID TotalPrice<br>C1 126.50<br>C2 102.25<br>C8 90.00<br>C6 66.75<br>C10 56.50<br>C5 30.10<br>C7 27.25<br>C3 10.50<br>C4 4.00<br>C9 1.25</pre><p>NOTE: use FinData, I have uploaded this dataset into Drive, YOu can find the file in Datasets folder in drive….</p><p>19. Req: Write a statement to print Total Price, Total Gross Sale Price, Total Sales by Segment, Product and Discount band, Country from FinData?</p><pre>Create Table FinData<br>(<br>Segment varchar(50),Country varchar(50),Product varchar(50),DiscountBand varchar(50),<br>UnitsSold int,ManufacturingPrice int,SalePrice int,GrossSales int,<br>Discounts int,Sales int,COGS int,Profit int,Date nvarchar<br>)<br><br>OR<br>CREATE TABLE [dbo].[FinData](<br> [Segment] [nvarchar](50) NOT NULL,<br> [Country] [nvarchar](50) NOT NULL,<br> [Product] [nvarchar](50) NOT NULL,<br> [Discount_Band] [nvarchar](50) NOT NULL,<br> [Units_Sold] [float] NOT NULL,<br> [Manufacturing_Price] [smallint] NOT NULL,<br> [Sale_Price] [smallint] NOT NULL,<br> [Gross_Sales] [float] NOT NULL,<br> [Discounts] [float] NOT NULL,<br> [Sales] [float] NOT NULL,<br> [COGS] [float] NOT NULL,<br> [Profit] [float] NOT NULL,<br> [Date] [nvarchar](50) NOT NULL<br>)</pre><pre>SELECT<br>    Country,<br>    Segment,<br>    Product,<br>    Discount_Band,<br>    SUM(Sale_Price) AS TotalPrice,<br>    SUM(Gross_Sales) AS TotalGrossSalePrice,<br>    SUM(Sales) AS TotalSales<br>FROM<br>    FinData<br>GROUP BY<br>    Country,<br>    Segment,<br>    Product,<br>    Discount_Band;</pre><p>20. Req: Print total Units sold, total price, total gross sales, total discount, total cogs, total profit by segment, product, <br>show the / filter the data to show data for Canada, France, Germany countries, AND for Midmarket and Governament Segments,<br> only for Carretere, Montana, Paseo, Velo, VTT Products, and exclude Negative profit values from the result set, <br>and total gross must be more than 100k and total cogs must be more than 110 k and less than 250 k, and total discount must more than 0?</p><pre>select Country,<br>    Segment,<br>    Product,<br>    SUM(Units_Sold) AS TotalUnits,<br>    SUM(Sale_Price) AS TotalPrice,<br>    SUM(Gross_Sales) AS TotalGrossSalePrice,<br>    SUM(Discounts) AS TotalDiscounts,<br> SUM(COGS) AS TotalCOGS,<br> SUM(Profit) AS TotalProfit<br>From FinData<br>WHERE Country IN(&#39;Canada&#39;,&#39;France&#39;,&#39;Germany&#39;)  AND Segment IN(&#39;Government&#39;,&#39;Midmarket&#39;)<br>AND Product IN(&#39;Carretere&#39;, &#39;Montana&#39;, &#39;Paseo&#39;, &#39;Velo&#39;, &#39;VTT&#39;)<br><br>GROUP BY<br>Country,<br>Segment,<br>Product<br><br>HAVING<br> SUM(Profit) &gt;= 0 AND SUM(Gross_Sales) &gt;= 100000 AND<br> SUM(COGS) &gt;= 110000 AND SUM(COGS) &lt;= 250000 AND SUM(Discounts) &gt; 0;<br><br> ANS<br> Canada Midmarket Paseo 14684 120 220260 22128.0000762939 146840 51291.9998168945<br>France Midmarket Paseo 17022 120 255330 14199.8998718262 170220 70910.099609375</pre><p>21. Req: Print list of Countries from FinData?</p><pre>Select DISTINCT country from FinData;<br><br>Canada<br>France<br>Germany<br>Mexico<br>United States of America</pre><p>22. Req: Print no of countries in FinData?</p><pre>Select  count(DISTINCT country) from FinData;<br><br>5</pre><p>23. 1. Create a table to store the product sales Transaction information, name it SalesTran, with the following columns: OrderID, Product, Price, Quantity?</p><pre>Create table SalesTran<br>(<br>OrderID int,<br>Product nvarchar(50),<br>Price  decimal(10,2),<br>Quantity int<br>);</pre><p>24. Req: Insert the below values into SalesTran table, Values:<br>OrderID | Product | Price | Quantity<br>100, A, 10.50, 2,<br>100, B, 2.02, 1,<br>101, C, 4.50, 1,<br>101, A, 5,25, 1,<br>101, B, 2.02, 3,<br>102, A, 10.50, 2,<br>102, B, 4.04, 2,<br>102, C, 9.0, 2,<br>102, D, 5, 1,<br>103, E, 1, 1<br>104, A, 5.25, 1,<br>104, H, 10, 1,<br>104, I, 15, 3,<br>105, H, 30, 3,<br>105, K, 4, 6 ,<br>106, L, 2, 10,<br>106, A, 4.04, 12<br>107, K, 4, 10<br>108, B, 1, 25<br>109, A, 4, 1<br>109, H, 30, 2<br>109, L, 2, 15<br>110, M, 5.55, 4<br>111, K, 6.50, 2</p><pre>insert into SalesTran (OrderID,Product,Price,Quantity) values<br>(100, &#39;A&#39;, 10.50, 2),<br>(100, &#39;B&#39;, 2.02, 1),<br>(101, &#39;C&#39;, 4.50, 1),<br>(101, &#39;A&#39;, 5.25, 1), <br>(101, &#39;B&#39;, 2.02, 3),<br>(102, &#39;A&#39;, 10.50, 2),<br>(102, &#39;B&#39;, 4.04, 2),<br>(102, &#39;C&#39;, 9.0, 2),<br>(102, &#39;D&#39;, 5, 1),<br>(103, &#39;E&#39;, 1, 1),<br>(104, &#39;A&#39;, 5.25, 1),<br>(104, &#39;H&#39;, 10, 1),<br>(104, &#39;I&#39;, 15, 3),<br>(105, &#39;H&#39;, 30, 3),<br>(105, &#39;K&#39;, 4, 6),<br>(106, &#39;L&#39;, 2, 10),<br>(106, &#39;A&#39;, 4.04, 12),<br>(107, &#39;K&#39;, 4, 10),<br>(108, &#39;B&#39;, 1, 25),<br>(109, &#39;A&#39;, 4, 1),<br>(109, &#39;H&#39;, 30, 2),<br>(109, &#39;L&#39;, 2, 15),<br>(110, &#39;M&#39;, 5.55, 4),<br>(111, &#39;K&#39;, 6.50, 2);<br>Answer:<br>OrderID Product Price Quantity<br>100 A 10.50 2<br>100 B 2.02 1<br>101 C 4.50 1<br>101 A 5.25 1<br>101 B 2.02 3<br>102 A 10.50 2<br>102 B 4.04 2<br>102 C 9.00 2<br>102 D 5.00 1<br>103 E 1.00 1<br>104 A 5.25 1<br>104 H 10.00 1<br>104 I 15.00 3<br>105 H 30.00 3<br>105 K 4.00 6<br>106 L 2.00 10<br>106 A 4.04 12<br>107 K 4.00 10<br>108 B 1.00 25<br>109 A 4.00 1<br>109 H 30.00 2<br>109 L 2.00 15<br>110 M 5.55 4<br>111 K 6.50 2</pre><p>25. Req: Count / print no of orders from SalesTran table using Order ID column?</p><pre>Select count(distinct OrderID) from SalesTran;<br>12<br>Total without distinct<br>Select count(OrderID) from SalesTran;<br>--24</pre><p>26. Req: Print total quantity by order id from SalesTran table?</p><pre>select SUM(Quantity) as TotalQuantity from SalesTran group by OrderID;<br>TotalQuantity<br>3<br>5<br>7<br>1<br>5<br>9<br>22<br>10<br>25<br>18<br>4<br>2</pre><p>27. Req: Print total price, total quantity by order id from SalesTran table?</p><pre>select SUM(Price) as TotalPrice, SUM(Quantity) as TotalQuantity from SalesTran group by OrderID;<br>TotalPrice  TotalQuantity<br>12.52 3<br>11.77 5<br>28.54 7<br>1.00 1<br>30.25 5<br>34.00 9<br>6.04 22<br>4.00 10<br>1.00 25<br>36.00 18<br>5.55 4<br>6.50 2</pre><p>28. Req: Write a statement to print Max Price, Min Price, Total Price, Avg price, Count of Products and Distinct count of production from SalesTran table,<br> and assign meaningful name to the output of all the columns in the result set??? (In one statement)?</p><pre>select Max(Price) as MaxPrice, Min(Price) as MinPrice , SUM(Price) as TotalPrice,<br>AVG(Price) as AveragePrice, COUNT(Product) as TotalProducts, <br>COUNT(DISTINCT Product) as TotalUniqueProducts From SalesTran; <br><br>MaxPrice MinPrice TotalPrice AveragePrice TotalProducts TotalUniqueProducts<br>30.00 1.00 177.17 7.382083 24 10</pre><p>29. Req: Print Total Price, Total Quantity by Product from SalesTran table, Filter the result set based on the below Filter condition:<br>Print only the Products which are contributing Total Price more than 50 ?</p><pre>Select SUM(Price) as TotalPrice, Sum(quantity) as TotalQuantity from SalesTran<br>GROUP BY Product<br>Having SUM(Price) &gt; 50;<br><br>TotalPrice TotalQuantity<br>70.00 6</pre><p>30. Req: Print No of Products by order id from SalesTran table, Show only the OrderId’s which has more than 3 products?</p><pre>select COUNT(Product) as Products From SalesTran group by OrderID<br>HAVING COUNT(Quantity) &gt; 3;<br><br> Products<br> 4</pre><p>31. Req: Print total sales, total quantity by order id from SalesTran table, filter the result set based on the below filter conditions:<br>Total Price must be more than 150?</p><pre>select SUM(Price) as TotalPrice, SUM(Quantity) as TotalQuantity From SalesTran<br>group by orderid;<br><br>TotalPrice TotalQuantity<br>12.52 3<br>11.77 5<br>28.54 7<br>1.00 1<br>30.25 5<br>34.00 9<br>6.04 22<br>4.00 10<br>1.00 25<br>36.00 18<br>5.55 4<br>6.50 2<br><br>select SUM(Price) as TotalPrice, SUM(Quantity) as TotalQuantity From SalesTran<br>group by orderid<br>HAVING SUM(Price) &gt; 150;<br><br>Empty Rows, No rowns are there greater than 150</pre><p>32. Req: Print total sales, total quantity by OrderID, Product, and filter the result set to show where total SalesTran more than 100?</p><pre>select SUM(Price) as TotalPrice, SUM(Quantity) as TotalQuantity From SalesTran<br>group by orderid, Product<br>HAVING SUM(Price) &gt; 100;<br><br>Empty Rows, No rowns are there greater than 100</pre><p>NOTE: Use Orders dataset to work on the below assignments..</p><p>33. Req: Print total sales, total profit, total discount by region, country, state, city, and print only the data which is falling under South region?</p><pre>Select region, SUM(Price) as TotalSales, SUM(Profit) as TotalProfit, SUM(discount) as TotalDiscount<br>FROM Orders<br>GROUP BY Region,Country,City,State<br>HAVING(region = &#39;South&#39;);</pre><p>34. Req: Print total sales, total profit, total discount by region, country, state, city, and print only the data which is falling under South region, <br>and Technology Category?</p><pre>Select region,SUM(Price) as TotalSales, SUM(Profit) as TotalProfit, SUM(discount) as TotalDiscount<br>FROM Orders<br>where category in (&#39;Technology&#39;)<br>GROUP BY Region,Country,City,State<br>HAVING(region = &#39;South&#39;);</pre><p>35. Req: Print total sales by country, and print only the countries which contribured more than 500k total sales?</p><pre>Select Country,SUM(Price) as TotalSales<br>FROM Orders<br><br>GROUP BY Country<br>HAVING(SUM(Price) &gt;  500000);<br><br>Country TotalSales<br>United States 818261.518521547</pre><p>36. Req: Print total profit by state, and print only the statement which are contributing more than 25k total profit and less than 50k total profit?</p><pre>Select State,SUM(Profit) as TotalProfit<br>FROM Orders<br><br>GROUP BY State<br>HAVING(SUM(Profit) &gt; 25000 AND SUM(Profit) &lt; 50000);<br><br>State TotalProfit<br>England 34410.7770766914<br>New York 31367.9737899005<br>California 31010.7038660198<br>Indiana 31054.3230447769</pre><p>37. Req: Print total profit by state, and print only the statement which are contributing more than 25k total profit and less than 50k total profit,<br> sort the resultset based on Total Profit?</p><pre>Select State,SUM(Profit) as TotalProfit<br>FROM Orders<br>GROUP BY State<br><br>HAVING(SUM(Profit) &gt; 25000 AND SUM(Profit) &lt; 50000)<br>order by SUM(Profit) ASC;<br><br>California 31010.7038660198<br>Indiana 31054.3230447769<br>New York 31367.9737899005<br>England 34410.7770766914</pre><p>38. Req: Print the complete data from order table, for EU region, within the EU Market, for Office Supplies Category?</p><pre>select * from dbo.orders<br>where market = &#39;EU&#39; AND category = &#39;Office Supplies&#39;;</pre><p>39. Req: Print total sales/price, total profit by Market and category?</p><pre>Select Market,category, SUM(Price) as TotalSales,SUM(Profit) as TotalProfit<br>FROM Orders<br>GROUP BY<br>Market,<br>category order by Market asc;</pre><p>40. Req: Print avg price, max profit by category and sub category, show / print this data for EU market?</p><pre>select AVG(Price) as AvergaePrice, Max(Profit) as MaxProfit <br>From Orders where market = &#39;EU&#39;<br>group by Category,Sub_Category;</pre><p>41. Req: Print total price, total profit, total shipping cost by city, state, country region, show data only EU market,<br> within the EU markte show only the cities which contributed total price more than 10k?</p><pre>select SUM(Price) as TotalPrice,SUM(Profit) as TotalProfit,SUM(Shipping_Cost) as TotalShippingCost<br>From Orders where market = &#39;EU&#39;<br>GROUP BY Region,Country,City,State<br>Having(SUM(Price) &gt; 10000);</pre><p>42. Req: Print total profit by city and state, and sort the result set based on total profit in the desc order?</p><pre>select City, SUM(Profit) as MaxProfit <br>From Orders<br>GROUP BY City,State<br>order by SUM(Profit) desc;</pre><p>Happy Reading,</p><p>Bala Prakash rao</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=269f32cf6714" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Styling And Design]]></title>
            <link>https://medium.com/@reddy.balu515/styling-and-design-fc6ae6cd162b?source=rss-90be45cc4cab------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc6ae6cd162b</guid>
            <category><![CDATA[styling-lwc]]></category>
            <category><![CDATA[lightning-web-component]]></category>
            <dc:creator><![CDATA[Bala prakash]]></dc:creator>
            <pubDate>Fri, 29 Dec 2023 04:16:38 GMT</pubDate>
            <atom:updated>2023-12-29T04:16:38.168Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Styling Lightning Web Components:</strong></p><p>Styling Lightning Web Components (LWC) involves using a combination of standard CSS (Cascading Style Sheets) and the Salesforce Lightning Design System (SLDS). SLDS provides a set of design guidelines, components, and styles that ensure a consistent and visually appealing look and feel across Salesforce applications. Here’s how you can style your Lightning Web Components:</p><ol><li>CSS Styling:<br>External Stylesheets:<br>You can use external stylesheets for your component by importing them in your JavaScript file:</li></ol><pre>// myComponent.js<br>import { LightningElement } from &#39;lwc&#39;;<br>import { loadStyle } from &#39;lightning/platformResourceLoader&#39;;<br>import myStyles from &#39;@salesforce/resourceUrl/myStyles&#39;;<br>export default class MyComponent extends LightningElement {<br> connectedCallback() {<br> // Load external stylesheet<br> Promise.all([<br> loadStyle(this, myStyles + &#39;/styles.css&#39;)<br> ]);<br> }<br>}</pre><p>Internal Styles:<br>You can also include internal styles directly in your component’s HTML file:</p><pre>&lt;! - myComponent.html →<br>&lt;template&gt;<br> &lt;div class=&quot;my-container&quot;&gt;<br> &lt;p class=&quot;my-text&quot;&gt;Hello, Lightning Web Components!&lt;/p&gt;<br> &lt;/div&gt;<br>&lt;/template&gt;</pre><pre>&lt;style&gt;<br> .my-container {<br> background-color: #f0f0f0;<br> padding: 10px;<br> }<br>.my-text {<br> color: #333;<br> font-size: 16px;<br> }<br>&lt;/style&gt;</pre><p>2. Using SLDS (Salesforce Lightning Design System):<br>Inheriting SLDS Styles:<br>By default, Lightning Web Components inherit the SLDS styling. You can use SLDS class names directly in your component’s HTML:</p><pre>&lt;! - myComponent.html →<br>&lt;template&gt;<br> &lt;div class=&quot;slds-box&quot;&gt;<br> &lt;p class=&quot;slds-text-heading_medium&quot;&gt;Hello, SLDS!&lt;/p&gt;<br> &lt;/div&gt;<br>&lt;/template&gt;<br>Styling SLDS Components:<br>You can also customize and style SLDS components using standard CSS:<br>&lt;! - myComponent.html →<br>&lt;template&gt;<br> &lt;div class=&quot;slds-box custom-box&quot;&gt;<br> &lt;p class=&quot;slds-text-heading_medium custom-text&quot;&gt;Customized SLDS!&lt;/p&gt;<br> &lt;/div&gt;<br>&lt;/template&gt;<br>&lt;style&gt;<br> .custom-box {<br> background-color: #ffcc00;<br> border: 1px solid #e0e0e0;<br> padding: 10px;<br> }<br>.custom-text {<br> color: #333;<br> font-size: 18px;<br> }<br>&lt;/style&gt;</pre><p>3. Scoped Styles:<br>Lightning Web Components support the use of scoped styles, preventing styles from leaking into other components. This is achieved by using the :host selector:</p><pre>&lt;! - myComponent.html →<br>&lt;template&gt;<br> &lt;div class=&quot;container&quot;&gt;<br> &lt;p class=&quot;text&quot;&gt;Scoped Styles!&lt;/p&gt;<br> &lt;/div&gt;<br>&lt;/template&gt;<br>&lt;style&gt;<br> :host .container {<br> background-color: #e0e0e0;<br> padding: 10px;<br> }<br>:host .text {<br> color: #333;<br> font-size: 16px;<br> }<br>&lt;/style&gt;</pre><p>By combining standard CSS techniques with SLDS, you can achieve a consistent and visually appealing styling for your Lightning Web Components</p><p>Happy Reading,</p><p>Bala Prakash</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc6ae6cd162b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Navigation and Communication in LWC]]></title>
            <link>https://medium.com/@reddy.balu515/navigation-and-communication-in-lwc-fefddb5dfaeb?source=rss-90be45cc4cab------2</link>
            <guid isPermaLink="false">https://medium.com/p/fefddb5dfaeb</guid>
            <category><![CDATA[lwc]]></category>
            <category><![CDATA[communication-in-lwc]]></category>
            <dc:creator><![CDATA[Bala prakash]]></dc:creator>
            <pubDate>Fri, 29 Dec 2023 03:25:24 GMT</pubDate>
            <atom:updated>2023-12-29T03:25:24.379Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Navigation and Communication in LWC</strong></p><p><strong>Navigation between Lightning Web Components?</strong></p><p>In Lightning Web Components (LWC), you can navigate between components using the lightning/navigation service or by implementing navigation using the NavigationMixin. Here’s a basic example using both methods:</p><p>Using lightning/navigation Service:<br>Create the Source Component:</p><p>html</p><pre>&lt;! - sourceComponent.html →<br>&lt;template&gt;<br> &lt;lightning-button label=&quot;Go to Destination&quot; onclick={navigateToDestination}&gt;&lt;/lightning-button&gt;<br>&lt;/template&gt;</pre><pre>// sourceComponent.js<br>import { LightningElement } from &#39;lwc&#39;;<br>import { NavigationMixin } from &#39;lightning/navigation&#39;;<br>export default class SourceComponent extends NavigationMixin(LightningElement) {<br> navigateToDestination() {<br> this[NavigationMixin.Navigate]({<br> type: &#39;standard__component&#39;,<br> attributes: {<br> componentName: &#39;c__destinationComponent&#39;<br> }<br> });<br> }<br>}</pre><p>Create the Destination Component:</p><pre>&lt;! - destinationComponent.html →<br>&lt;template&gt;<br> &lt;lightning-card title=&quot;Destination Component&quot;&gt;<br> &lt;! - Content of the destination component →<br> &lt;/lightning-card&gt;<br>&lt;/template&gt;</pre><pre>// destinationComponent.js<br>import { LightningElement } from &#39;lwc&#39;;<br>export default class DestinationComponent extends LightningElement {<br> // Logic for the destination component<br>}</pre><p>Using NavigationMixin:<br>Create the Source Component:</p><pre>&lt;! - sourceComponent.html →<br>&lt;template&gt;<br> &lt;lightning-button label=&quot;Go to Destination&quot; onclick={navigateToDestination}&gt;&lt;/lightning-button&gt;<br>&lt;/template&gt;</pre><pre>// sourceComponent.js<br>import { LightningElement } from &#39;lwc&#39;;<br>import { NavigationMixin } from &#39;lightning/navigation&#39;;<br>export default class SourceComponent extends NavigationMixin(LightningElement) {<br> navigateToDestination() {<br> this[NavigationMixin.Navigate]({<br> type: &#39;standard__component&#39;,<br> attributes: {<br> componentName: &#39;c__destinationComponent&#39;<br> }<br> });<br> }<br>}</pre><p>Create the Destination Component:</p><pre>&lt;! - destinationComponent.html →<br>&lt;template&gt;<br> &lt;lightning-card title=&quot;Destination Component&quot;&gt;<br> &lt;! - Content of the destination component →<br> &lt;/lightning-card&gt;<br>&lt;/template&gt;</pre><pre>// destinationComponent.js<br>import { LightningElement } from &#39;lwc&#39;;<br>export default class DestinationComponent extends LightningElement {<br> // Logic for the destination component<br>}</pre><p>Need to add both components to your Salesforce org, and then use the Lightning App Builder to place the sourceComponent on a Lightning page. Clicking the “Go to Destination” button in the sourceComponent should navigate you to the destinationComponent</p><p><strong>Communicating between components using events in LWC?</strong></p><p>In Lightning Web Components (LWC), components can communicate with each other by dispatching and handling custom events. This allows you to pass data and trigger actions between components. Here’s an example demonstrating communication between parent and child components using events:</p><p>Example: Parent and Child Components Communication<br>Create the Parent Component:</p><pre>&lt;! - parentComponent.html →<br>&lt;template&gt;<br> &lt;lightning-card title=&quot;Parent Component&quot;&gt;<br> &lt;p&gt;Parent Data: {parentData}&lt;/p&gt;<br> &lt;c-child-component onchildclick={handleChildClick}&gt;&lt;/c-child-component&gt;<br> &lt;/lightning-card&gt;<br>&lt;/template&gt;</pre><pre>// parentComponent.js<br>import { LightningElement } from &#39;lwc&#39;;<br>export default class ParentComponent extends LightningElement {<br> parentData = &#39;Data from Parent&#39;;<br>handleChildClick(event) {<br> // Handle the custom event dispatched by the child component<br> this.parentData = event.detail.message;<br> }<br>}</pre><p>Create the Child Component:</p><pre>&lt;! - childComponent.html →<br>&lt;template&gt;<br> &lt;lightning-card title=&quot;Child Component&quot;&gt;<br> &lt;p&gt;Child Data: {childData}&lt;/p&gt;<br> &lt;lightning-button label=&quot;Send Data to Parent&quot; onclick={sendDataToParent}&gt;&lt;/lightning-button&gt;<br> &lt;/lightning-card&gt;<br>&lt;/template&gt;</pre><pre>// childComponent.js<br>import { LightningElement, api } from &#39;lwc&#39;;<br>export default class ChildComponent extends LightningElement {<br> @api childData = &#39;Data from Child&#39;;<br>sendDataToParent() {<br> // Dispatch a custom event to notify the parent component<br> const customEvent = new CustomEvent(&#39;childclick&#39;, {<br> detail: {<br> message: &#39;Data from Child&#39;<br> }<br> });<br> this.dispatchEvent(customEvent);<br> }<br>}</pre><p>In this example:</p><p>The ParentComponent contains a Lightning card with a piece of data (parentData) and the ChildComponent.<br>The ChildComponent contains a Lightning card with a piece of data (childData) and a button that triggers the sendDataToParent method.<br>When the button in the ChildComponent is clicked, a custom event (childclick) is dispatched with a message.<br>The ParentComponent handles the custom event (onchildclick) and updates its parentData with the message from the child.<br>This demonstrates a simple way to communicate between parent and child components using custom events</p><p>Happy Reading,</p><p>Bala Prakash Rao</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fefddb5dfaeb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Data Binding in Lightning Web Component?]]></title>
            <link>https://medium.com/@reddy.balu515/what-is-data-binding-in-lightning-web-component-fedcfdb74f5d?source=rss-90be45cc4cab------2</link>
            <guid isPermaLink="false">https://medium.com/p/fedcfdb74f5d</guid>
            <category><![CDATA[lightning-web-component]]></category>
            <category><![CDATA[lwc]]></category>
            <category><![CDATA[data-binding-in-lwc]]></category>
            <dc:creator><![CDATA[Bala prakash]]></dc:creator>
            <pubDate>Thu, 28 Dec 2023 18:09:55 GMT</pubDate>
            <atom:updated>2023-12-28T18:09:55.319Z</atom:updated>
            <content:encoded><![CDATA[<p>Data binding in Lightning Web Components (LWC) is a mechanism that establishes a connection between the data in the JavaScript controller and the HTML template of a component. This connection allows the two parts of the component to stay synchronized, ensuring that changes in the data are reflected in the user interface, and vice versa.<br>There are two main types of data binding in LWC:<br><strong>One-Way Data Binding:</strong><br>In one-way data binding, changes in the JavaScript controller are reflected in the HTML template or vice versa, but not both. This is denoted by the use of double curly braces ({{}}) in the HTML template.</p><pre>&lt;!-- myComponent.html --&gt;<br>&lt;template&gt;<br>    &lt;p&gt;{message}&lt;/p&gt;<br>&lt;/template&gt;</pre><pre>// myComponent.js<br>import { LightningElement } from &#39;lwc&#39;;<br><br>export default class MyComponent extends LightningElement {<br>    message = &#39;Hello, World!&#39;;<br>}</pre><ol><li>In this example, the value of the message property in the JavaScript controller is displayed in the HTML template. If the value of message changes in the controller, the change is automatically reflected in the template.</li><li><strong>Two-Way Data Binding:</strong></li></ol><p>Two-way data binding allows changes in the JavaScript controller to update the HTML template, and changes in the template to update the controller. This is achieved using the @track decorator.</p><pre>&lt;!-- myComponent.html --&gt;<br>&lt;template&gt;<br>    &lt;input type=&quot;text&quot; value={twoWayBinding} oninput={handleInputChange} /&gt;<br>&lt;/template&gt;</pre><pre>// myComponent.js<br>import { LightningElement, track } from &#39;lwc&#39;;<br><br>export default class MyComponent extends LightningElement {<br>    @track twoWayBinding = &#39;Initial Value&#39;;<br><br>    handleInputChange(event) {<br>        this.twoWayBinding = event.target.value;<br>    }<br>}</pre><p>In this example, the twoWayBinding property is bound to an input field. Changes in the input field trigger the handleInputChange method, updating the value of twoWayBinding in the controller. Conversely, changes to twoWayBinding in the controller are reflected in the input field.</p><p>Data binding simplifies the development process by automatically synchronizing data between the JavaScript controller and the HTML template, reducing the need for manual DOM manipulation and enhancing the reactivity of Lightning web components.</p><p>Happy Reading,</p><p>Bala Prakash Rao</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fedcfdb74f5d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What are Decorators in Lightning Web Component?]]></title>
            <link>https://medium.com/@reddy.balu515/what-are-decorators-in-lightning-web-component-f196e9b0b452?source=rss-90be45cc4cab------2</link>
            <guid isPermaLink="false">https://medium.com/p/f196e9b0b452</guid>
            <category><![CDATA[lwc]]></category>
            <category><![CDATA[decorators]]></category>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[lightning-web-component]]></category>
            <dc:creator><![CDATA[Bala prakash]]></dc:creator>
            <pubDate>Thu, 28 Dec 2023 17:53:29 GMT</pubDate>
            <atom:updated>2023-12-28T17:53:29.841Z</atom:updated>
            <content:encoded><![CDATA[<p>In Lightning Web Components (LWC), decorators are special identifiers in JavaScript that provide additional functionality or metadata to the components. Here are details about three commonly used decorators in LWC:</p><h3>1. @api Decorator:</h3><p>Purpose:</p><ul><li>Exposes a public property or method from a parent component to a child component.</li></ul><p>Usage:</p><ul><li>Applied to a public property or method in the JavaScript file of the child component.</li></ul><pre>import { LightningElement, api } from &#39;lwc&#39;;<br><br>export default class ChildComponent extends LightningElement {<br>    @api message = &#39;Hello from Child Component&#39;;<br>}</pre><p>Example:</p><p>A parent component can set or get the value of the message property in the child component.</p><pre>&lt;!-- parentComponent.html --&gt;<br>&lt;template&gt;<br>    &lt;c-child-component message=&quot;Hello from Parent Component&quot;&gt;&lt;/c-child-component&gt;<br>&lt;/template&gt;</pre><p>2. @track Decorator:</p><p>Purpose:</p><p>Marks a property for tracking so that changes to the property trigger the component to rerender.</p><p>Usage:</p><p>Applied to a property in the JavaScript file of the component</p><pre>import { LightningElement, track } from &#39;lwc&#39;;<br><br>export default class MyComponent extends LightningElement {<br>    @track count = 0;<br><br>    handleClick() {<br>        this.count += 1;<br>    }<br>}</pre><p>Example:</p><p>When the handleClick method is called, the component rerenders, and any markup bound to the count property reflects the updated value.</p><pre>&lt;!-- myComponent.html --&gt;<br>&lt;template&gt;<br>    &lt;p&gt;Count: {count}&lt;/p&gt;<br>    &lt;button onclick={handleClick}&gt;Increment&lt;/button&gt;<br>&lt;/template&gt;</pre><h3>3. @wire Decorator:</h3><p>Purpose:<br>Connects a Lightning web component to a wire adapter to receive and send data between the component and Salesforce.<br>Usage:<br>Applied to a method in the JavaScript file that is used to call an Apex method or get data from Salesforce.</p><pre>import { LightningElement, wire } from &#39;lwc&#39;;<br>import getAccountList from &#39;@salesforce/apex/MyController.getAccountList&#39;;<br><br>export default class MyComponent extends LightningElement {<br>    @wire(getAccountList)<br>    accounts;<br>}</pre><p>Example:<br>The accounts property is automatically populated with data returned by the getAccountList Apex method.</p><pre>&lt;!-- myComponent.html --&gt;<br>&lt;template&gt;<br>    &lt;ul&gt;<br>        &lt;template for:each={accounts.data} for:item=&quot;account&quot;&gt;<br>            &lt;li key={account.Id}&gt;{account.Name}&lt;/li&gt;<br>        &lt;/template&gt;<br>    &lt;/ul&gt;<br>&lt;/template&gt;</pre><p>These decorators help enhance the functionality and capabilities of Lightning web components, making them more powerful and flexible for building dynamic and interactive user interfaces in Salesforce.</p><p>Happy Reading,</p><p>Bala Prakash Rao</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f196e9b0b452" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[when you build an Angular application, the lazy-loaded modules will be compiled and bundled?]]></title>
            <link>https://medium.com/@reddy.balu515/when-you-build-an-angular-application-the-lazy-loaded-modules-will-be-compiled-and-bundled-028293673fdf?source=rss-90be45cc4cab------2</link>
            <guid isPermaLink="false">https://medium.com/p/028293673fdf</guid>
            <category><![CDATA[lazy-loading]]></category>
            <category><![CDATA[lazy-loading-in-angular]]></category>
            <category><![CDATA[webpack]]></category>
            <dc:creator><![CDATA[Bala prakash]]></dc:creator>
            <pubDate>Wed, 27 Dec 2023 19:11:44 GMT</pubDate>
            <atom:updated>2023-12-27T19:11:44.686Z</atom:updated>
            <content:encoded><![CDATA[<p>Yes, when you build an Angular application, the lazy-loaded modules will be compiled and bundled, just like the eagerly loaded modules. The key difference is that the lazy-loaded modules are compiled into separate chunks or files, known as “lazy chunks.”</p><p>When you build an Angular application using tools like the Angular CLI, the build process (handled by tools such as Webpack) generates separate bundles for the main application and each lazy-loaded module. These bundles are loaded on-demand as the user navigates through the application.</p><p>Here’s a simplified overview of the process:</p><ol><li>Build Command:</li></ol><ul><li>When you run the build command (ng build for Angular CLI), the build tool (e.g., Webpack) analyzes your application&#39;s code and dependencies.</li></ul><ol><li>Lazy Chunks:</li></ol><ul><li>For lazy-loaded modules, the build tool generates separate chunks (JavaScript files) for each module. These chunks are not included in the main bundle but are created as separate files.</li></ul><ol><li>Main Bundle:</li></ol><ul><li>The main bundle typically contains the core application code and eagerly loaded modules.</li></ul><ol><li>Deployment:</li></ol><ul><li>When you deploy your Angular application, you will have a set of files, including the main bundle and separate lazy-loaded chunks.</li></ul><ol><li>Loading on Demand:</li></ol><ul><li>As users navigate to routes associated with lazy-loaded modules, the corresponding lazy chunks are fetched and executed on-demand, reducing the initial loading time.</li></ul><p>This modular approach helps in optimizing the initial loading performance by loading only the essential parts of the application upfront and deferring the loading of less critical parts until they are needed. It also facilitates better code splitting, making it easier to manage and maintain large Angular applications.</p><p>Happy Reading,</p><p>Bala prakash Rao</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=028293673fdf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Is lazy Loading in Angular]]></title>
            <link>https://medium.com/@reddy.balu515/what-is-lazy-loading-in-angular-277901c5c856?source=rss-90be45cc4cab------2</link>
            <guid isPermaLink="false">https://medium.com/p/277901c5c856</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[lazy-loading]]></category>
            <dc:creator><![CDATA[Bala prakash]]></dc:creator>
            <pubDate>Wed, 27 Dec 2023 19:00:42 GMT</pubDate>
            <atom:updated>2023-12-27T19:00:42.632Z</atom:updated>
            <content:encoded><![CDATA[<p>Lazy loading in Angular refers to a technique where you only load the modules or components that are necessary for rendering the current view, rather than loading the entire application upfront. This helps in reducing the initial loading time of the application, as only the essential code is fetched initially, and additional parts of the application are loaded on-demand as the user navigates through the application.</p><p>In Angular, lazy loading is often used with the Angular Router to load modules asynchronously. Here’s a basic explanation of how lazy loading works in Angular:</p><ol><li>Module Configuration:</li></ol><ul><li>Break your Angular application into feature modules, each representing a specific section or functionality of your app.</li><li>Configure your routes in the Angular Router to associate a lazy-loaded module with a specific route.</li></ul><ol><li>Routing Configuration:</li></ol><ul><li>When setting up your routes, use the loadChildren property of the route configuration to specify the path to the module that should be lazily loaded.</li><li>The path to the module is specified using the module’s file path relative to the root of the application.</li></ul><pre>// Example of lazy loading in Angular Router<br>const routes: Routes = [<br>  { path: &#39;home&#39;, component: HomeComponent },<br>  { path: &#39;lazy&#39;, loadChildren: () =&gt; import(&#39;./lazy/lazy.module&#39;).then(m =&gt; m.LazyModule) },<br>  // Other routes...<br>];</pre><ol><li>Webpack Integration:</li></ol><ul><li>Lazy loading is made possible by the dynamic import syntax, supported by tools like Webpack.</li><li>Webpack, the default build tool for Angular applications, generates separate chunks of code for each lazy-loaded module.</li></ul><ol><li>Usage:</li></ol><ul><li>When the user navigates to a route associated with a lazy-loaded module, Angular fetches the corresponding module file asynchronously.</li></ul><p>Lazy loading is particularly beneficial for large applications, as it allows you to reduce the initial bundle size and improve the application’s startup performance. It’s important to note that lazy loading works well with the Angular CLI and tools like Webpack, so make sure your project setup supports these features.</p><p>Happy Reading,</p><p>Bala Prakash Rao</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=277901c5c856" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>