<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>codeproject &#8211; Sibeesh Passion</title>
	<atom:link href="https://sibeeshpassion.com/tag/codeproject/feed/" rel="self" type="application/rss+xml" />
	<link>https://sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Fri, 11 Jan 2019 09:40:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>/wp-content/uploads/2017/04/Sibeesh_Passion_Logo_Small.png</url>
	<title>codeproject &#8211; Sibeesh Passion</title>
	<link>https://sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>IoTHubTrigger Azure Function and Azure IoT Hub</title>
		<link>https://sibeeshpassion.com/iothubtrigger-azure-function-and-azure-iot-hub/</link>
					<comments>https://sibeeshpassion.com/iothubtrigger-azure-function-and-azure-iot-hub/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Thu, 27 Dec 2018 11:47:52 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[IoT]]></category>
		<category><![CDATA[Azure Function]]></category>
		<category><![CDATA[Azure IoT]]></category>
		<category><![CDATA[codeproject]]></category>
		<category><![CDATA[IoT Hub]]></category>
		<category><![CDATA[IoTHubTrigger]]></category>
		<category><![CDATA[MXChip]]></category>
		<guid isPermaLink="false">https://sibeeshpassion.com/?p=13494</guid>

					<description><![CDATA[[toc] Introduction For the past few days I am playing with my MXChip and had written some articles about the same, you should be able to find those here. Here in this article, we will send some data to our Azure IoT hub and we will connect an Azure Function with our IoT Hub using IoTHubTrigger Event Hub Trigger Attribute. If you are ready, let&#8217;s do this. Background As I said this article is part of my IoT article series, so if you have read my previous articles on this topic, it may be easier for you to understand the [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>[toc]</p>



<h2 class="wp-block-heading">Introduction</h2>



<p>For the past few days I am playing with my MXChip and had written some articles about the same, you should be able to find those <a href="https://sibeeshpassion.com/category/iot/">here</a>. Here in this article, we will send some data to our Azure IoT hub and we will connect an Azure Function with our IoT Hub using IoTHubTrigger Event Hub  Trigger Attribute. If you are ready, let&#8217;s do this. </p>



<h2 class="wp-block-heading">Background</h2>



<p>As I said this article is part of my IoT article series, so if you have read my previous articles on this topic, it may be easier for you to understand the concept. Before you start this article, please make sure that you had already created an Azure IoT hub and it is running. You can always send the messages to this IoT Hub either by connecting the actual device, let&#8217;s say an MXChip or using a simulating device.</p>



<h2 class="wp-block-heading">IoTHubTrigger Demo</h2>



<h3 class="wp-block-heading">Creating an Azure Function App</h3>



<p>I am going to create an Azure Function App in Visual Studio, if you are not sure about how we can create and publish the Azure Function, please read <a href="https://sibeeshpassion.com/azure-function-as-output-job-topology-of-an-azure-stream-analytics-job/#play-with-azure-function">this section</a> of my previous article. Let&#8217;s create a new solution now. </p>



<figure class="wp-block-image"><img fetchpriority="high" decoding="async" width="650" height="375" src="https://sibeeshpassion.com/wp-content/uploads/2018/12/IoTHubTrigger.jpg" alt="" class="wp-image-13495" srcset="/wp-content/uploads/2018/12/IoTHubTrigger.jpg 650w, /wp-content/uploads/2018/12/IoTHubTrigger-300x173.jpg 300w, /wp-content/uploads/2018/12/IoTHubTrigger-400x231.jpg 400w" sizes="(max-width: 650px) 100vw, 650px" /><figcaption>IoTHubTrigger</figcaption></figure>



<p>Once you click OK, a new Azure Function will be generated for you with some initial codes in it. Let&#8217;s edit the Function as below.</p>



<pre class="wp-block-code"><code>using Microsoft.Azure.EventHubs;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
using System.Text;
using IoTHubTrigger = Microsoft.Azure.WebJobs.EventHubTriggerAttribute;

namespace IoTHubTrigger_Azure_Function_and_Azure_IoT_Hub
{
    public static class IoTHubFunc
    {
        [FunctionName("IoTHubData")]
        public static void Run(
            [IoTHubTrigger("messages/events", Connection = "IoTHubTriggerConnection", ConsumerGroup ="FuncGroup")]EventData message, 
            ILogger log)
        {
            log.LogInformation($"C# IoT Hub trigger function processed a message: {Encoding.UTF8.GetString(message.Body.Array)}");
        }
    }
}</code></pre>



<p>Here the IoTHubTriggerConnection is the connection string we are providing in the local.settings.json file. The consumer group will come into the play if you have many applications which need to be receiving the data from your IoT Hub. Below is the class definition of EventHubTriggerAttribute.</p>



<pre class="wp-block-code"><code>public sealed class EventHubTriggerAttribute : Attribute
    {
        public EventHubTriggerAttribute(string eventHubName);

        public string EventHubName { get; }
        public string ConsumerGroup { get; set; }
        public string Connection { get; set; }
    }</code></pre>



<h3 class="wp-block-heading">Send data to the Azure IoT Hub</h3>



<p>As I mentioned earlier, there are two ways you can send the data to the Azure IoT Hub.</p>



<ol class="wp-block-list"><li>Using a device, for example, MXChip </li><li><a href="https://sibeeshpassion.com/an-introduction-to-azure-stream-analytics-job/#run-the-stream-analytics-job-and-see-the-data-in-the-database">Simulated device</a></li></ol>



<p>Once the data is been sending, you can see the message received count in Azure IoT Hub in the overview section. </p>



<h3 class="wp-block-heading">Run the Azure Function</h3>



<p>So, the IoT Hub is started receiving the messages from the device, and now we can use our Azure Function to pull the data from the IoT hub with the help of IoT hub Trigger. Run your Function App, Simulated Device application and see the output. </p>



<figure class="wp-block-image"><img decoding="async" width="650" height="484" src="https://sibeeshpassion.com/wp-content/uploads/2018/12/IoTHubTrigger-Demo-WIth-Simulated-App.jpg" alt="" class="wp-image-13496" srcset="/wp-content/uploads/2018/12/IoTHubTrigger-Demo-WIth-Simulated-App.jpg 650w, /wp-content/uploads/2018/12/IoTHubTrigger-Demo-WIth-Simulated-App-300x223.jpg 300w, /wp-content/uploads/2018/12/IoTHubTrigger-Demo-WIth-Simulated-App-400x298.jpg 400w" sizes="(max-width: 650px) 100vw, 650px" /><figcaption>IoT Hub Trigger Output </figcaption></figure>



<p>As you can see in the output, our Azure Function app is receiving the data from Azure IoT hub instantly. Now you can perform any actions with this data. I will leave that to you.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>Wow!. Now we have learned,</p>



<ul class="wp-block-list"><li>Usage of Azure IoT Hub Trigger in Azure Function</li><li>Creating Azure Function App</li><li>See the Data from Azure IoT Hub in the Azure Function App</li></ul>



<p>You can always ready my IoT articles&nbsp;<a href="https://sibeeshpassion.com/category/iot/">here</a>.</p>



<h2 class="wp-block-heading">Your turn. What do you think?</h2>



<p>Thanks a lot for reading. Did I miss anything that you may think which is needed in this article? Could you find this post as useful? Kindly do not forget to share me your feedback.</p>



<p>Kindest Regards<br>Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sibeeshpassion.com/iothubtrigger-azure-function-and-azure-iot-hub/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Iterating/Loop Through Your Component Property in Render Function in React</title>
		<link>https://sibeeshpassion.com/iterating-loop-through-your-component-property-in-render-function-in-react/</link>
					<comments>https://sibeeshpassion.com/iterating-loop-through-your-component-property-in-render-function-in-react/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Mon, 29 Oct 2018 14:28:32 +0000</pubDate>
				<category><![CDATA[React]]></category>
		<category><![CDATA[codeproject]]></category>
		<category><![CDATA[React Component]]></category>
		<category><![CDATA[React Component Properties]]></category>
		<category><![CDATA[React Render Function and Loop]]></category>
		<guid isPermaLink="false">https://sibeeshpassion.com/?p=13314</guid>

					<description><![CDATA[[toc] Introduction I understand that you need to build some UI elements dynamically in your component&#8217;s render function in React. Yes! the only way is to loop through the items, you can either use a for loop or a map function to do so. But the real question is, are we allowed to do that in react? Unfortunately, not in a direct way, you may face some difficulty especially if you come from an Angular background. You were probably getting an error as &#8221; unused expression, expected an assignment or function call&#8221;, and now you are here in this page [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>[toc]</p>
<h2>Introduction</h2>
<p>I understand that you need to build some UI elements dynamically in your component&#8217;s render function in <a href="https://sibeeshpassion.com/category/react/">React</a>. Yes! the only way is to loop through the items, you can either use a for loop or a map function to do so. But the real question is, are we allowed to do that in react? Unfortunately, not in a direct way, you may face some difficulty especially if you come from an Angular background. You were probably getting an error as &#8221; unused expression, expected an assignment or function call&#8221;, and now you are here in this page for an easy solution. It isn&#8217;t that hard to achieve, I will explain how. I hope you will like it.</p>
<h2>Background</h2>
<p>I have an array of addresses and I need to show this in a print template, so I thought of creating a separate component which iterates through the item property. And each array element has its own property and I wanted to generate labels for each item. Here I am going to explain how I did it.</p>
<h2>Let&#8217;s start coding</h2>
<p>The first thing is, I have an interface for the address list properties as below.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">import { IAddressData } from "../../../interfaces/IAddressData";
export interface IAddressListProps {
    items: IAddressData[];
}</pre>
<p>Now I have created a component called PrintAddressList.tsx and written some code.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">import * as React from "react";
import { IAddressListProps } from '../../detailPage/components/interfaces/IAddressListProps';

export class PrintAddressList extends React.Component&lt;IAddressListProps, {}&gt;{
  constructor(props: IAddressListProps) {
    super(props);
  }

  public render(): React.ReactElement&lt;IAddressListProps&gt; {
    return (
      &lt;div&gt;
      &lt;/div&gt;
    );
  }
}</pre>
<p>And I need to have my custom labels for each address inside the div element in the render function. To do so, I had created a private function called createAddressCard which will loop through my props and return the HTML I need.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">private createAddressCard = () =&gt; {
    let parent = [];
    this.props.items.map((address) =&gt; {
      parent.push(&lt;div style={{ padding: '10px', border: '1px solid #ccc', margin: '5px' }}&gt;
        &lt;label&gt;{config.colNames.addressList.clmnAddressType}: &lt;/label&gt;
        &lt;label&gt;{address.Adressart}&lt;/label&gt;&lt;br /&gt;
        &lt;label&gt;{config.colNames.addressList.clmnCompanyName}: &lt;/label&gt;
        &lt;label&gt;{address.Firma}&lt;/label&gt;&lt;br /&gt;
        &lt;label&gt;{config.colNames.addressList.clmnPlaceName}: &lt;/label&gt;
        &lt;label&gt;{address.Ort}&lt;/label&gt;&lt;br /&gt;
        &lt;label&gt;{config.colNames.addressList.clmnZipCode}: &lt;/label&gt;
        &lt;label&gt;{address.PLZ}&lt;/label&gt;&lt;br /&gt;
        &lt;label&gt;{config.colNames.addressList.clmnTelephone}: &lt;/label&gt;
        &lt;label&gt;{address.Telefon}&lt;/label&gt;&lt;br /&gt;
      &lt;/div&gt;);
    });
    return parent;
  }</pre>
<p>Now I can easily call this function inside the render function.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">public render(): React.ReactElement&lt;IAddressListProps&gt; {
    return (
      &lt;div&gt;
        {this.createAddressCard()}
      &lt;/div&gt;
    );
  }</pre>
<p>Below is the complete code for the component.</p>
<p><a href="https://gist.github.com/SibeeshVenu/d2e11ed225a0568ded27c6f8fec0956c">https://gist.github.com/SibeeshVenu/d2e11ed225a0568ded27c6f8fec0956c</a></p>
<h2><span id="conclusion_1"><span id="conclusion">Conclusion</span></span></h2>
<p>In this post, we have learned how we can iterate our components properties inside a render function in the React component, for creating custom elements dynamically.</p>
<h2><span id="your-turn-what-do-you-think">Your turn. What do you think?</span></h2>
<p>Thanks a lot for reading. Did I miss anything that you may think which is needed? Could you find this post as useful? If yes, please like/share/clap for me. Thanks in advance.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sibeeshpassion.com/iterating-loop-through-your-component-property-in-render-function-in-react/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
