<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Chris Naismith</title>
    <description>The latest articles on DEV Community by Chris Naismith (@naismith).</description>
    <link>https://dev.to/naismith</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F125472%2F3cf63a69-9ceb-4433-8ff0-b440310e50eb.png</url>
      <title>DEV Community: Chris Naismith</title>
      <link>https://dev.to/naismith</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/naismith"/>
    <language>en</language>
    <item>
      <title>New Year New Goals - My 2020 Resolutions</title>
      <dc:creator>Chris Naismith</dc:creator>
      <pubDate>Wed, 01 Jan 2020 05:01:41 +0000</pubDate>
      <link>https://dev.to/naismith/new-year-new-goals-my-2020-professional-resolutions-1ehd</link>
      <guid>https://dev.to/naismith/new-year-new-goals-my-2020-professional-resolutions-1ehd</guid>
      <description>&lt;p&gt;2019 was a crazy year for myself, both professionally and personally. In the span of 2 months I got married, bought and moved into my first house, and started a new job. Talk about stress. But in the final moments of 2019, I hope to plan out and goal set for the upcoming year and decade.&lt;/p&gt;

&lt;p&gt;Hopefully writing down my goals and sharing them, will encourage me to stick to them.&lt;/p&gt;

&lt;h2&gt;
  
  
  💻 Writing More
&lt;/h2&gt;

&lt;p&gt;I wrote my first blog post on dev.to in 2019. In 2020 I plan to write 12 different blog posts by the end of the year. Sharing knowledge is incredibly important, either for your team or bettering the community.&lt;/p&gt;

&lt;p&gt;I had been meaning to write much more in 2019, but every time I was close to publishing a post I always second guessed myself. But hopefully by jumping 'into the deep end' I can keep up this momentum and continue to share my insights/knowledge with others, and learn back from them.&lt;/p&gt;

&lt;h2&gt;
  
  
  📚 Reading More
&lt;/h2&gt;

&lt;p&gt;Reading is a great way to learn from others. Wether it's books, blog posts, articles you can always learn something new. This year, similar to writing more, I'd like to read 12 new books. As a kid I loved reading, and in 2019 I started reading again after not reading for so long.&lt;/p&gt;

&lt;p&gt;In addition to books, I plan to read more blog posts and articles. I have no specific goal in mind, but I look forward to the new content that 2020 has in store.&lt;/p&gt;

&lt;h2&gt;
  
  
  ⌨️ A New Front End Framework
&lt;/h2&gt;

&lt;p&gt;In our industry we joke about new frameworks coming out every month, day or hour. When developing on the front end, I tend to lean towards React. While I love React, I am interested in playing with some alternatives in either strengthening my love for React or finding something better. &lt;/p&gt;

&lt;p&gt;Being comfortable for far too long in anything can cause you to plateau in your skills. Which is why I plan in 2020 to pickup Vue.JS or Svelte for a small project to see if the grass is greener on the other side.&lt;/p&gt;

&lt;h2&gt;
  
  
  🌐 Open Source
&lt;/h2&gt;

&lt;p&gt;Hacktoberfest came and went this year and I failed to participate. Obviously it's optional but the idea of contributing to the community in which I benefit from is of huge interest to me. I'm hoping by the end of the year to have made a beneficial impact on at least 1 open source project.&lt;/p&gt;

&lt;p&gt;My current interest is in creating a plugin for the open source CMS Strapi. If you are not familiar with it, I recommend taking a look at it.&lt;/p&gt;

&lt;h2&gt;
  
  
  👫 Community
&lt;/h2&gt;

&lt;p&gt;I created a developer meetup in the city I grew up in as there's little to no social community. I hope to continue the success of it in 2020 by making new friendships, helping educate others, and learn from others over some pizza.&lt;/p&gt;

&lt;h2&gt;
  
  
  📣 Talking
&lt;/h2&gt;

&lt;p&gt;I had never given a tech talk until this year. I hope to continue some talks in the new year as it has been a lot of fun (in fact my most recent talk I converted into my first ever blog post - 2 birds with one stone!).&lt;/p&gt;

&lt;h2&gt;
  
  
  ☯️ Balance
&lt;/h2&gt;

&lt;p&gt;I recently just stopped a part time job as it was severely cutting into my personal time. Early mornings and late nights was starting to cause strain on my mental health and relationships as it would take time to recover. But one thing I hope to do in this new decade is take the time to enjoy the world around me and my life with my new wife. Noone on their death bed wishes they worked more.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;There's certainly more I could add to this list, getting promotions, or a raise. But I think that would be in most people's resolutions.&lt;/p&gt;

&lt;p&gt;What's on your list? Got any book recommendations? Did you meet your goals? I'd love to hear your comments down below.&lt;/p&gt;

</description>
      <category>2020</category>
      <category>personal</category>
      <category>resolutions</category>
    </item>
    <item>
      <title>Cross Tab Communication with Javascript</title>
      <dc:creator>Chris Naismith</dc:creator>
      <pubDate>Fri, 27 Dec 2019 02:13:32 +0000</pubDate>
      <link>https://dev.to/naismith/cross-tab-communication-with-javascript-1hc9</link>
      <guid>https://dev.to/naismith/cross-tab-communication-with-javascript-1hc9</guid>
      <description>&lt;p&gt;About a month ago an interesting problem came up at work, how can I listen to a form being submitted that may be in another tab? It's something that if it was in the same tab, would be much more straight forward. But I also wanted to know can I send messages between these two, or more, tabs.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is Cross Tab Communication?
&lt;/h1&gt;

&lt;p&gt;Cross Tab Communication is the ability of multiple tabs, windows, frames of iframes (further known as an instance) to send and receive 'messages' to and from other instances.&lt;/p&gt;

&lt;h1&gt;
  
  
  Limitations / Gotchas
&lt;/h1&gt;

&lt;p&gt;This does come with some drawbacks. This will only work with domains on the same-origin.&lt;/p&gt;

&lt;p&gt;You will not be able to use this across HTTP and HTTPS.&lt;br&gt;
You will not be able to use this across different hosts.&lt;br&gt;
You will not be able to use this across different ports.&lt;/p&gt;
&lt;h1&gt;
  
  
  How is this useful?
&lt;/h1&gt;

&lt;p&gt;Before getting into some demos, I figure I would go over why this can be useful. Sometimes your users are going to have multiple instances of your site open, and how we handle their experience can be quite important. &lt;/p&gt;

&lt;p&gt;For example, Dan Abramov's blog &lt;a href="https://overreacted.io/"&gt;https://overreacted.io/&lt;/a&gt; has a toggle for a dark mode/light mode. Using this, you could switch all open instances to the preferred theme without refreshing.&lt;/p&gt;
&lt;h1&gt;
  
  
  Examples / Demos
&lt;/h1&gt;
&lt;h3&gt;
  
  
  Example 1 - LocalStorage
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://klpei.csb.app/"&gt;External link if you don't want the preview&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/session-storage-example-1-klpei"&gt;
&lt;/iframe&gt;
&lt;br&gt;
&lt;iframe src="https://codesandbox.io/embed/session-storage-example-1-klpei"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;How this works is by setting/modifying a value in local storage or session storage on load of the application. When this happens, an event is fired that can be listened to on any other instance. This event contains information such as the key that was modified, the previous value, the new value and much more. If you're familiar with React, this is similar to how you can compare the previous props, to the current props in class lifecycle method componentDidUpdate.&lt;/p&gt;

&lt;h4&gt;
  
  
  Drawbacks of Example 1
&lt;/h4&gt;

&lt;p&gt;There are some draw backs to using this method. For one, you can not store objects in local storage/session storage unless they are stringified. This means you would have to parse any of these values which may not be a huge deal, but in my opinion is not ideal. &lt;/p&gt;

&lt;p&gt;The second draw back is that the event will not be fired if a value is updated to the same value. In my example I get around that limitation to setting the key &lt;code&gt;loaded&lt;/code&gt; to Date.now().&lt;/p&gt;

&lt;h3&gt;
  
  
  Example 2 - BroadcastChannel
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://qckg2.csb.app/"&gt;External link if you don't want the preview&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/broadcastchannel-message-demo-1-qckg2"&gt;
&lt;/iframe&gt;
&lt;br&gt;
&lt;iframe src="https://codesandbox.io/embed/broadcastchannel-message-demo-1-qckg2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;In this example, I'm using the BroadcastChannel API. To do this, you create a new BroadcastChannel using a name (Similar to an IRC channel).&lt;/p&gt;

&lt;p&gt;After subscribing to the channel you are returned an instance of the BroadcastChannel object, which in this example we use two parts of. You can send a message using the &lt;code&gt;postMessage&lt;/code&gt; function, or attach a function to the &lt;code&gt;onmessage&lt;/code&gt; property.&lt;/p&gt;

&lt;p&gt;Similar with Example 1, and messages you send in one instance will be received in other instances. Along with the ability to subscribe to the same channel multiple times.&lt;/p&gt;

&lt;h4&gt;
  
  
  Drawbacks/Benefits of Example 2
&lt;/h4&gt;

&lt;p&gt;Unlike Example 1, you are able to post full objects, arrays and other pieces of data.&lt;/p&gt;

&lt;p&gt;However, Example 2 is a little bit more complicated and may be overkill depending on what you're trying to do.&lt;/p&gt;

&lt;p&gt;Support for the BroadcastChannel API is also limited. Compared to local storage (globally at 92%), BroadcastChannel is at almost 76%. Chrome and Firefox both support it, with no support from IE, Safari and Edge. (Chromium Edge does support it, but is still considered in Beta as of this post).&lt;/p&gt;

&lt;h1&gt;
  
  
  More Usecases
&lt;/h1&gt;

&lt;p&gt;This could be used in a CMS to let the user know they already have an instance open when trying to modify something, or to keep it in sync across tabs.&lt;/p&gt;

&lt;p&gt;Authentication/locked content could be unlocked when logging in so that other windows are not out of sync.&lt;/p&gt;

&lt;p&gt;Changing a profile picture&lt;/p&gt;

&lt;p&gt;Communication between iframes.&lt;/p&gt;

&lt;p&gt;Changing themes of a website, and syncing those changes across all tabs. &lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;I don't think that this is going to be ground breaking and change the way we make our applications. But I do think implementing this across some features of our applications could improve the user experience. &lt;/p&gt;

&lt;p&gt;If you have any other use cases you think this would be useful for, I'd love to hear it!&lt;/p&gt;

&lt;h1&gt;
  
  
  Resources
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://caniuse.com/#feat=mdn-api_window_localstorage"&gt;CanIUse - Localstorage&lt;/a&gt;&lt;br&gt;
&lt;a href="https://caniuse.com/#feat=broadcastchannel"&gt;CanIUse - BroadcastChannel&lt;/a&gt;&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API"&gt;MDN - BroadcastChannel&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
