<?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[VueJobs - Medium]]></title>
        <description><![CDATA[Vue.js Jobs - Medium]]></description>
        <link>https://medium.com/vuejobs?source=rss----5b4bab0ed644---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>VueJobs - Medium</title>
            <link>https://medium.com/vuejobs?source=rss----5b4bab0ed644---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 12:28:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/vuejobs" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Vue Component for Dynamically Updating Human Readable Time]]></title>
            <link>https://medium.com/vuejobs/vue-component-for-dynamically-updating-human-readable-time-7b30a04d36e7?source=rss----5b4bab0ed644---4</link>
            <guid isPermaLink="false">https://medium.com/p/7b30a04d36e7</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[vue]]></category>
            <dc:creator><![CDATA[Jilson Thomas]]></dc:creator>
            <pubDate>Tue, 08 May 2018 20:12:06 GMT</pubDate>
            <atom:updated>2018-05-08T20:09:18.960Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve recently created an npm package for vue, which will allow you to dynamically update your human readable time slots without any page refresh. Confused? Let me give you an example:</p><p>You’re mostly likely to have something like the following in your applicaiton:</p><pre>posted 3 minutes ago</pre><p>Most of the cases, the time will be updated when you refresh the page. But for example in facebook, it’s automatically updated every minute. So, the display changes to posted 4 minutes ago, 5, 6… etc</p><p>The following package: <a href="https://www.npmjs.com/package/vue-moments-ago">https://www.npmjs.com/package/vue-moments-ago</a> will allow you to do the same in your Vue projects.</p><p>Just install the package:</p><pre>npm install vue-moments-ago</pre><p>and in your component file script tag,</p><pre>import VueMomentsAgo from &#39;vue-moments-ago&#39;</pre><pre>export default{<br>  components: {<br>    VueMomentsAgo<br>  }<br>}</pre><p>in the template, use:</p><pre>&lt;vue-moments-ago prefix=&quot;posted&quot; suffix=&quot;ago&quot; date=&quot;2018-05-02T20:22:22.285Z&quot;&gt;&lt;/vue-moments-ago&gt;</pre><p>result:</p><pre>posted 2 minutes ago</pre><p>The date prop accept ISO 8601 format(default format of moment.js)</p><p>Now your time will be automatically updated without any refresh. Checkout this <a href="https://codesandbox.io/s/m4x9kw090p">Live Demo</a></p><p><strong>NOTE:</strong> This package is still in the infant stage and any suggestion or contribution would be greatly appreciated.</p><p><a href="https://vuejobs.com/"><strong>VueJobs.com</strong></a></p><p>If you are a Vue.js developer and looking for a job, subscribe to <a href="https://www.getrevue.co/profile/govuejs">our mailing list.</a> Or if you are looking for a Vue.js developer, feel free to post your job requirements here in <a href="https://vuejobs.com/">vuejobs.com</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*5gcuct6rUWOC876lVoWBZA.png" /><figcaption>VueJobs.com</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b30a04d36e7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/vuejobs/vue-component-for-dynamically-updating-human-readable-time-7b30a04d36e7">Vue Component for Dynamically Updating Human Readable Time</a> was originally published in <a href="https://medium.com/vuejobs">VueJobs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel Development with Elixir + Vue + Hot Reloading]]></title>
            <link>https://medium.com/vuejobs/laravel-development-with-elixir-vue-hot-reloading-a598ad2670f8?source=rss----5b4bab0ed644---4</link>
            <guid isPermaLink="false">https://medium.com/p/a598ad2670f8</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[gulp]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[vue]]></category>
            <dc:creator><![CDATA[Jilson Thomas]]></dc:creator>
            <pubDate>Wed, 21 Feb 2018 17:01:37 GMT</pubDate>
            <atom:updated>2016-10-31T20:51:33.589Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*sUI87Y-FI6W1R2wTtsgvpg.png" /><figcaption>Laravel Elixir with Vue.js and hot reloading</figcaption></figure><p>So, here is the thing. You are developing an application in Laravel and Vue.js. Mostly likely, you are using Laravel Elixir to compile your asset and to create Gulp tasks. Now, if you are not using Laravel, but simple HTML/CSS framework, you might be using Webpack.</p><p>Things are getting complicated when you start introducing Vue.js components in to your application and every time you want to see a change in the component logic, template, css, you need to gulp it, refresh the page. Or at least the gulp watch is running and you still need a page refresh. What happens when there is a page refresh? That’s right. You are loosing all the application state. Imagine you are modifying a component within a modal popup. Every time you make a change to the vue component, you need to refresh and get the popup up and running to see the changes. That’s when we use Hot reloading plugins! This option would keep your state as it is, and inject any changes made to your Vue components without a page refresh. That’s right. You make a change, press save! You can instantly see the changes reflected on the browser.</p><p>Now, we know that its there in the Webpack and if you are using the latest versions (at the time of this writing) Webpack 2.0 and Vue.js 2.0 has this option enabled by default. Here is a <a href="https://www.youtube.com/watch?v=CwuhNshj3x8">link</a> towards the video where the creator of Vue.js Evan You explaining it.</p><p>Now that we know it’s there in Webpack, what we really want is this option in Laravel Elixir. But unfortunately, we do not have this option in Laravel Elixir by default. So, I want to show you guys how did I accomplish this in my Laravel application.</p><p><strong>Package.json</strong></p><pre>{<br>  &quot;private&quot;: <strong>true</strong>,<br>  &quot;devDependencies&quot;: {<br>    &quot;gulp&quot;: &quot;^3.8.8&quot;<br>  },<br>  &quot;dependencies&quot;: {<br>    &quot;babel-plugin-transform-runtime&quot;: &quot;^6.15.0&quot;,<br>    &quot;babel-runtime&quot;: &quot;^6.11.6&quot;,<br>    &quot;browserify-hmr&quot;: &quot;^0.3.5&quot;,<br>    &quot;laravel-elixir&quot;: &quot;^4.0.4&quot;,<br>    &quot;vue&quot;: &quot;^1.0.28&quot;,<br>    &quot;vue-hot-reload-api&quot;: &quot;^1.3.3&quot;,<br>    &quot;vueify&quot;: &quot;^6.0.1&quot;,<br>    &quot;vueify-insert-css&quot;: &quot;^1.0.0&quot;<br>  }<br>}</pre><p><strong>gulpfile.js</strong></p><pre><strong>var <em>elixir </em></strong>= <em>require</em>(&#39;laravel-elixir&#39;);<br><strong>var <em>gutils </em></strong>= <em>require</em>(&#39;gulp-util&#39;);<br><strong>var  <em>b </em></strong>= <strong><em>elixir</em></strong>.config.js.browserify;<br><br><strong>if</strong>(<strong><em>gutils</em></strong>.env._.indexOf(&#39;watch&#39;) &gt; -1){<br>    <strong><em>b</em></strong>.plugins.push({<br>        name: &quot;browserify-hmr&quot;,<br>        options : {}<br>    });<br>}<br><br><strong><em>b</em></strong>.transformers.push({<br>    name: &quot;vueify&quot;,<br>    options : {}<br>});<br><br><strong><em>elixir</em></strong>(<strong>function</strong>(mix) {<br>    mix.sass(&#39;app.scss&#39;)<br>        .browserify(&#39;app.js&#39;)<br>        .version([&#39;css/app.css&#39;, &#39;js/app.js&#39;]);<br>});</pre><p>Now run:</p><pre>npm install</pre><p>Once all the packages are installed, run gulp with watch</p><pre>gulp watch</pre><p>Now this should compile all your assets. If you are missing any packages and are not mentioned here, it would be shown as a missing error and you can install it using <strong><em>npm insall package-name</em></strong> command.</p><p>That’s all. The hot reloading should be up and ready. Try to make any changes to any vue components and you’ll see the changes reflected on the browser without a page refresh. But in order for this to work, I assume you are using .vue component extension files. It has three sections such as template, script, style. So any changes you make here would reflect in the browser.</p><p>If you also want browserSync, add the following code to the gulpfile.js</p><pre>mix.browserSync({<br>    proxy: &#39;myapplicationname.dev&#39;,<br>    files: [<br>        <strong><em>elixir</em></strong>.config.appPath + &#39;/**/*.php&#39;,<br>        <strong><em>elixir</em></strong>.config.get(&#39;public.css.outputFolder&#39;) + &#39;/**/*.css&#39;,<br>        <strong><em>elixir</em></strong>.config.get(&#39;public.versioning.buildFolder&#39;) + &#39;/rev-manifest.json&#39;,<br>        &#39;resources/views/**/*.php&#39;<br>    ],<br>});</pre><p><strong>Closing</strong></p><p>If you have any other means of achieving the same hot reloading in Laravel or found any missing packages in the package.json file, feel free to comment down.</p><p><a href="https://vuejobs.com/"><strong>VueJobs.com</strong></a></p><p>If you are a Vue.js developer and looking for a job, subscribe to <a href="https://www.getrevue.co/profile/govuejs">our mailing list.</a> Or if you are looking for a Vue.js developer, feel free to post your job requirements here in <a href="https://vuejobs.com/">vuejobs.com</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*5gcuct6rUWOC876lVoWBZA.png" /><figcaption>VueJobs.com</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a598ad2670f8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/vuejobs/laravel-development-with-elixir-vue-hot-reloading-a598ad2670f8">Laravel Development with Elixir + Vue + Hot Reloading</a> was originally published in <a href="https://medium.com/vuejobs">VueJobs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vue-router page loading effect]]></title>
            <link>https://medium.com/vuejobs/vue-router-page-loading-effect-67290a3247a1?source=rss----5b4bab0ed644---4</link>
            <guid isPermaLink="false">https://medium.com/p/67290a3247a1</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[vue]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[vuejs]]></category>
            <dc:creator><![CDATA[Jilson Thomas]]></dc:creator>
            <pubDate>Wed, 21 Feb 2018 17:01:25 GMT</pubDate>
            <atom:updated>2018-09-06T13:09:27.056Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V-k_XLA5HE5HQad7lPesPQ.png" /><figcaption>Vue-router page loading effect</figcaption></figure><p>If you are building a Single Page Application (SPA) using vue-router and APIs, you are most likely dealing with vue components. Each page will be vue component. So, when you load each page, you’ll have to wait for the API to get the result from the server in order for vue to render the page.</p><p>Let’s just take take the example of a user profile page.</p><p>Our <strong>user.vue</strong> would look like this:</p><pre>&lt;template&gt;<br>    &lt;div&gt;<br>        &lt;h2 v-text=&quot;user.name&quot;&gt;&lt;/h2&gt;<br>        &lt;p v-text=&quot;user.description&quot;&gt;&lt;/p&gt;<br>    &lt;/div&gt;<br>&lt;/template&gt;<br>&lt;script&gt;<br>    <strong>export default</strong>{<br>        data(){<br>            <strong>return</strong>{<br>                user: {}<br>            }<br>        }<br>    }<br>&lt;/script&gt;</pre><p>We’ll fetch the data from the server during the transition as below:</p><pre>&lt;script&gt;<br>    <strong>export default</strong>{<br>        data(){<br>            <strong>return</strong>{<br>                user: {}<br>            }<br>        },<br>        route: {<br>            data: <strong>function </strong>(transition) {<br>                <strong>this</strong>.getUserDetails(transition);<br>            }<br>        },<br><br>        methods: {<br><br>            getUserDetails(transition)<br>            {<br>                <strong>this</strong>.$http.get(&#39;/users/&#39; + <strong>this</strong>.$route.params.userName)<br>                    .then(<strong>function </strong>(response) {<br>                        <strong>this</strong>.user = response.data;<br>                        transition.next();<br>                    });<br><br>            }<br>        }<br>    }<br>&lt;/script&gt;</pre><p>So in this case, we have access to a variable <strong>$loadingRouteData</strong></p><p>You’ll be able to hide all your page elements and show a loader just like facebook or medium itself.</p><pre>&lt;div v-if=&quot;$loadingRouteData&quot;&gt;<br>    &lt;div class=&quot;white-widget grey-bg author-area&quot;&gt;<br>    &lt;div class=&quot;auth-info row&quot;&gt;<br>    &lt;div class=&quot;timeline-wrapper&quot;&gt;<br>    &lt;div class=&quot;timeline-item&quot;&gt;<br>        &lt;div class=&quot;animated-background&quot;&gt;<br>            &lt;div class=&quot;background-masker header-top&quot;&gt;&lt;/div&gt;<br>            &lt;div class=&quot;background-masker header-left&quot;&gt;&lt;/div&gt;<br>            &lt;div class=&quot;background-masker header-right&quot;&gt;&lt;/div&gt;<br>            &lt;div class=&quot;background-masker header-bottom&quot;&gt;&lt;/div&gt;<br>            &lt;div class=&quot;background-masker subheader-left&quot;&gt;&lt;/div&gt;<br>            &lt;div class=&quot;background-masker subheader-right&quot;&gt;&lt;/div&gt;<br>            &lt;div class=&quot;background-masker subheader-bottom&quot;&gt;&lt;/div&gt;<br>        &lt;/div&gt;<br>    &lt;/div&gt;<br>    &lt;/div&gt;<br>    &lt;/div&gt;<br>    &lt;/div&gt;<br>&lt;/div&gt;<br>&lt;div v-if=&quot;!$loadingRouteData&quot;&gt;<br>    &lt;div&gt;<br>        &lt;h2 v-text=&quot;user.name&quot;&gt;&lt;/h2&gt;<br>        &lt;p v-text=&quot;user.description&quot;&gt;&lt;/p&gt;<br>    &lt;/div&gt;<br>&lt;/div&gt;</pre><p>and for the facebook/medium like loading effect, use the following CSS</p><pre>.timeline-item {<br>  background: #fff;<br>  border-bottom: 1px solid #f2f2f2;<br>  padding: 25px;<br>  margin: 0 auto;<br>}<br><br>@keyframes placeHolderShimmer{<br>  0%{<br>    background-position: -468px 0<br>  }<br>  100%{<br>    background-position: 468px 0<br>  }<br>}<br><br>.animated-background {<br>  animation-duration: 1s;<br>  animation-fill-mode: forwards;<br>  animation-iteration-count: infinite;<br>  animation-name: placeHolderShimmer;<br>  animation-timing-function: linear;<br>  background: #f6f7f8;<br>  background: linear-gradient(to right, #eeeeee 8%, #dddddd 18%, #eeeeee 33%);<br>  background-size: 800px 104px;<br>  height: 40px;<br>  position: relative;<br>}<br><br>.background-masker {<br>  background: #fff;<br>  position: absolute;<br>}<br><br>/* Every thing below this is just positioning */<br><br>.background-masker.header-top,<br>.background-masker.header-bottom,<br>.background-masker.subheader-bottom {<br>  top: 0;<br>  left: 40px;<br>  right: 0;<br>  height: 10px;<br>}<br><br>.background-masker.header-left,<br>.background-masker.subheader-left,<br>.background-masker.header-right,<br>.background-masker.subheader-right {<br>  top: 10px;<br>  left: 40px;<br>  height: 8px;<br>  width: 10px;<br>}<br><br>.background-masker.header-bottom {<br>  top: 18px;<br>  height: 6px;<br>}<br><br>.background-masker.subheader-left,<br>.background-masker.subheader-right {<br>  top: 24px;<br>  height: 6px;<br>}<br><br><br>.background-masker.header-right,<br>.background-masker.subheader-right {<br>  width: auto;<br>  left: 300px;<br>  right: 0;<br>}<br><br>.background-masker.subheader-right {<br>  left: 230px;<br>}<br><br>.background-masker.subheader-bottom {<br>  top: 30px;<br>  height: 10px;<br>}<br><br>.background-masker.content-top,<br>.background-masker.content-second-line,<br>.background-masker.content-third-line,<br>.background-masker.content-second-end,<br>.background-masker.content-third-end,<br>.background-masker.content-first-end {<br>  top: 40px;<br>  left: 0;<br>  right: 0;<br>  height: 6px;<br>}<br><br>.background-masker.content-top {<br>  height:20px;<br>}<br><br>.background-masker.content-first-end,<br>.background-masker.content-second-end,<br>.background-masker.content-third-end{<br>  width: auto;<br>  left: 380px;<br>  right: 0;<br>  top: 60px;<br>  height: 8px;<br>}<br><br>.background-masker.content-second-line  {<br>  top: 68px;<br>}<br><br>.background-masker.content-second-end {<br>  left: 420px;<br>  top: 74px;<br>}<br><br>.background-masker.content-third-line {<br>  top: 82px;<br>}<br><br>.background-masker.content-third-end {<br>  left: 300px;<br>  top: 88px;<br>}</pre><p>That’s it. You now have an amazing vue-router loader. You can even make it as a separate component and use it anywhere you like. I’ll show you how to use it in another article.</p><p><strong>Closing</strong></p><p>This is just a simple tutorial for the vue-router component loading and we can optimize it in many ways. Next one would be the content-loader vue component that you can reuse in all places.</p><p><a href="https://vuejobs.com/"><strong>VueJobs.com</strong></a></p><p>If you are a Vue.js developer and looking for a job, subscribe to <a href="https://www.getrevue.co/profile/govuejs">our mailing list.</a> Or if you are looking for a Vue.js developer, feel free to post your job requirements here in <a href="https://vuejobs.com/">vuejobs.com</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*5gcuct6rUWOC876lVoWBZA.png" /><figcaption>VueJobs.com</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d7gJTNtyA7oDaVjTad6TKg.jpeg" /><figcaption>VueConfTO 2018 | 14–16 November 2018 | Fairmont Royal York Toronto</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67290a3247a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/vuejobs/vue-router-page-loading-effect-67290a3247a1">Vue-router page loading effect</a> was originally published in <a href="https://medium.com/vuejobs">VueJobs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reusable User Link Popover Component Using Vue.js]]></title>
            <link>https://medium.com/vuejobs/reusable-user-link-popover-component-using-vue-js-d37e525a8d27?source=rss----5b4bab0ed644---4</link>
            <guid isPermaLink="false">https://medium.com/p/d37e525a8d27</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[vue]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jilson Thomas]]></dc:creator>
            <pubDate>Wed, 21 Feb 2018 17:00:51 GMT</pubDate>
            <atom:updated>2016-11-02T19:09:53.786Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yd9d9zk-xetBHC3PNlXf8g.png" /><figcaption>Reusable popover link using Vue.js components</figcaption></figure><p>While browsing through facebook or quora, have you ever hover over a user name? You’ll get a quick info about the user through a popover. Today we’ll try to make a similar popover using Vue.js. We’ll make it as a component so you can reuse it as many times as you want.</p><p>Here is the Component</p><pre><strong><em>Vue</em></strong>.component(&#39;user-link&#39;, {<br>    template: &#39;#user-link-template&#39;,<br>    props: [&#39;user&#39;],<br>    data: <strong>function </strong>() {<br>        <strong>return </strong>{<br>            showPopup: <strong>false</strong>,<br>            timer: &#39;&#39;,<br>            isInInfo: <strong>false<br>        </strong>}<br>    },<br><br>    methods: {<br><br>        hover: <strong>function</strong>()<br>        {<br>            <strong>let </strong>vm = <strong>this</strong>;<br>            <strong>this</strong>.timer = setTimeout(<strong>function</strong>() {<br>                vm.showPopover();<br>            }, 600);<br>        },<br><br>        hoverOut: <strong>function</strong>()<br>        {<br>            <strong>let </strong>vm = <strong>this</strong>;<br>            clearTimeout(vm.timer);<br>            <strong>this</strong>.timer = setTimeout(<strong>function</strong>() {<br>                <strong>if</strong>(!vm.isInInfo)<br>                {<br>                    vm.closePopover();<br>                }<br>            }, 200);<br>        },<br><br>        hoverInfo: <strong>function</strong>()<br>        {<br>            <strong>this</strong>.isInInfo = <strong>true</strong>;<br>        },<br><br>        hoverOutInfo: <strong>function</strong>()<br>        {<br>            <strong>this</strong>.isInInfo = <strong>false</strong>;<br>            <strong>this</strong>.hoverOut();<br>        },<br><br>        showPopover: <strong>function</strong>()<br>        {<br>            <strong>this</strong>.showPopup = <strong>true</strong>;<br>        },<br><br>        closePopover: <strong>function</strong>()<br>        {<br>            <strong>this</strong>.showPopup = <strong>false</strong>;<br>        }<br>    }<br>})</pre><p>and the main file:</p><pre><strong>new <em>Vue</em></strong>({<br>    el: &#39;#app&#39;,<br>    data: <strong>function</strong>(){<br>        <strong>return </strong>{<br>            user: {name: &#39;Jilson Thomas&#39;},<br>            user2: {name: &#39;VueJobs.com&#39;}<br>        }<br>    }<br><br>});</pre><p>So, here is the template for the component</p><pre>&lt;script type=&quot;text/x-template&quot; id=&quot;user-link-template&quot;&gt;<br>    &lt;div class=&quot;inline&quot;&gt;<br>        &lt;a href=&quot;#&quot; v-on:mouseover=&quot;hover&quot; v-on:mouseout=&quot;hoverOut&quot;&gt;{{ user.name }}&lt;/a&gt;<br>        &lt;div class=&quot;user-popover&quot; v-if=&quot;showPopup&quot; transition=&quot;fade&quot; v-on:mouseover=&quot;hoverInfo&quot; v-on:mouseout=&quot;hoverOutInfo&quot;&gt;<br>            &lt;h3&gt;{{ user.name }}&lt;/h3&gt;<br>            &lt;button&gt;Follow {{user.name}}&lt;/button&gt;<br>        &lt;/div&gt;<br>    &lt;/div&gt;<br>&lt;/script&gt;</pre><p>You can modify this component with your own content and needs. We have a prop where we can pass any user and the component will render according to that.</p><p>Some quick styling:</p><pre>body{<br>    font-family: &#39;Montserrat&#39;, sans-serif;<br>}<br>a{<br>    color: #42b983;<br>}<br><br>#app{<br>    height: 400px;<br>}<br><br>p{<br>    font-size: 14px;<br>}<br>h3{<br>    margin: 5px 0;<br>}<br>.is-flex{<br>    height: 100%;<br>    width: 100%;<br>    display: flex;<br>    flex-direction: column;<br>    align-items: center;<br>    justify-content: center;<br>}<br>.inline{<br>    display: inline-block;<br>    position: relative;<br>}<br>.user-popover{<br>    position: absolute;<br>    width: 200px;<br>    background: #fff;<br>    border: 1px solid #42b983;<br>    padding: 10px 20px;<br>    box-shadow: 0 6px 6px rgba(16, 16, 16, 0.04), 0 6px 6px rgba(0, 0, 0, 0.05);<br>    z-index:999;<br>}<br><br>button{<br>    background: #42b983;<br>    font-family: &#39;Montserrat&#39;, sans-serif;<br>    border: 1px solid #42b983;<br>    padding: 12px;<br>    font-size: 12px;<br>    color: #fff;<br>    outline: none;<br>    display: inline-block;<br>    text-align: center;<br>    padding: 6px 12px;<br>    border-radius: 3px;<br>    user-select: none;<br>    margin: 0 0 5px 0;<br>}</pre><p>and we’re all ready to go. You can now re-use this component as given below.</p><pre>&lt;div id=&quot;app&quot;&gt;<br>    &lt;p&gt;&lt;user-link :user=user&gt;&lt;/user-link&gt; created this tutorial!&lt;/p&gt;<br>    &lt;p&gt;Hey there! visit us on &lt;user-link :user=user2&gt;&lt;/user-link&gt;&lt;/p&gt;<br>&lt;/div&gt;</pre><p>Here is a <a href="https://jsfiddle.net/jillztom/wd1yq680/">Demo</a>:</p><p><a href="https://vuejobs.com/"><strong>VueJobs.com</strong></a></p><p>If you are a Vue.js developer and looking for a job, subscribe to <a href="https://www.getrevue.co/profile/govuejs">our mailing list.</a> Or if you are looking for a Vue.js developer, feel free to post your job requirements here in <a href="https://vuejobs.com/">vuejobs.com</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*5gcuct6rUWOC876lVoWBZA.png" /><figcaption>VueJobs.com</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d37e525a8d27" width="1" height="1" alt=""><hr><p><a href="https://medium.com/vuejobs/reusable-user-link-popover-component-using-vue-js-d37e525a8d27">Reusable User Link Popover Component Using Vue.js</a> was originally published in <a href="https://medium.com/vuejobs">VueJobs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a global event bus in Vue.js]]></title>
            <link>https://medium.com/vuejobs/create-a-global-event-bus-in-vue-js-838a5d9ab03a?source=rss----5b4bab0ed644---4</link>
            <guid isPermaLink="false">https://medium.com/p/838a5d9ab03a</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[vuejs]]></category>
            <dc:creator><![CDATA[Jilson Thomas]]></dc:creator>
            <pubDate>Wed, 21 Feb 2018 17:00:20 GMT</pubDate>
            <atom:updated>2018-09-06T13:11:45.749Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*02Mo8HRP6RjT5UMTaVJhHw.png" /><figcaption>Global Event Bus in Vue.js</figcaption></figure><p>Let’s imagine you are creating a relatively big application using vue. This means, you’ll have a large collection of components in different levels. Now, you need a proper mechanism for communicating between the components.</p><p>You can pass data through the “props” to the child components. That’s fine. But what if you need to communicate with some other component which is not a child component? Things are getting complicated there. But not anymore. Let’s take advantage of the event mechanism in vue.</p><p>There are many ways to solve this problem. I’ll show you a simple and effective mechanism that I used in a recent project. We’ll be communicating with the components through a global event bus. Now what’s an event bus? Yeah that’s right. Just like the name indicates, it transport data between components and provide a means for communication between any components. Let’s see how we can create a global event bus in vue.</p><p>In your main.js file, lets start by defining a global event bus as follows:</p><pre>Vue.prototype.$eventHub = <strong>new </strong>Vue(); // Global event bus</pre><pre><strong>new </strong>Vue({<br>  el: &#39;#app&#39;,<br>  router: Router,<br>  template: &#39;&lt;App/&gt;&#39;,<br>  store: store,<br>});</pre><p>In this way, you do not have to export the event bus in each components.</p><p>Now, from any component, you can access and emit an event to the bus as follows:</p><pre>methods: {</pre><pre>login(){<br>     // login logic<br>     // on success <br>     <strong>this</strong>.$eventHub.$emit(&#39;logged-in&#39;);</pre><pre>  }<br>}</pre><p>Now, in the other component, you need to listen to the event and add handlers for them. It has to be done in the “created” life hook of vue instance. Also, you need to make sure that the event listener is turned off before you destroy the component.</p><pre>data(){<br>    <strong>return </strong>{<br>        //data<br>    }<br>},<br>created() {<br>    <strong>this</strong>.$eventHub.$on(&#39;logged-in&#39;, <strong>this</strong>.getCurrentUser);<br>},<br>beforeDestroy() {<br>    <strong>this</strong>.$eventHub.$off(&#39;logged-in&#39;);<br>},<br>methods: {<br>   getCurrentUser(){</pre><pre>     // Get current user information<br>    }</pre><pre>}</pre><p>This event bus can be listened from any component in your application and the handlers can be assigned to perform any actions based on the event emitted.</p><p>I’ll show you another example:</p><pre>&lt;!--name.vue--&gt;<br><br>&lt;template&gt;<br>    &lt;div&gt;<br>        &lt;h1&gt;Hello World, I&#39;m {{ <strong><em>name </em></strong>}}&lt;/h1&gt;<br>    &lt;/div&gt;<br>&lt;/template&gt;<br><br>&lt;script&gt;<br>    <strong>export default</strong>{<br>        data(){<br>            <strong>return </strong>{<br>                name: &#39;Foo&#39;<br>            }<br>        },<br><br>        created() {<br>            <strong>this</strong>.$eventHub.$on(&#39;change-name&#39;, <strong>this</strong>.changeName)<br>        },<br><br>        beforeDestroy(){<br>            <strong>this</strong>.$eventHub.$off(&#39;change-name&#39;);<br>        },<br><br>        methods: {<br><br>            changeName(name) <br>            {<br>         // name will be automatically transported to the parameter.<br>                <strong>this</strong>.name = name;<br>            }<br><br>        }<br>    }<br>&lt;/script&gt;</pre><p>Second component:</p><pre>&lt;!--change-name.vue--&gt;<br>&lt;template&gt;<br>    &lt;div&gt;<br>        &lt;input type=&quot;text&quot; v-model=&quot;newName&quot;&gt;<br>        &lt;button @click.prevent=&quot;changeName()&quot;&gt;&lt;/button&gt;<br>    &lt;/div&gt;<br>&lt;/template&gt;<br>&lt;script&gt;<br>    <strong>export default</strong>{<br>        data(){<br>            <strong>return </strong>{<br>                newName: &#39;&#39;<br>            }<br>        },<br>        <br>        methods: {<br>            changeName()<br>            {<br>                <strong>this</strong>.$eventHub.$emit(&#39;change-name&#39;, <strong>this</strong>.newName);<br>            }<br>        }<br>    }<br>&lt;/script&gt;</pre><p>In this example, when you type and press the button, an event is emitted in to the global bus. A listener from the first component listen for the event and changes the name with the new name typed.</p><p>If you have any question or doubts, feel free to ask here at the comments and I can update the article or try to give you the solutions.</p><p><strong>Update</strong></p><p>You should be careful when using global event handlers. It might not be ideal for all cases. Lets imagine you’ve a widget which open a dynamic form upon a button click. If you have a list of such widgets on the same page, the global event listener might trigger on all widgets at the same time and it causes all widgets to show the dynamic form at the same time. So in such cases, try to use child-parent emits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d7gJTNtyA7oDaVjTad6TKg.jpeg" /><figcaption>VueConfTO 2018 | 14–16 November 2018 | Fairmont Royal York Toronto</figcaption></figure><p><a href="https://vuejobs.com/"><strong>VueJobs.com</strong></a></p><p>If you are a Vue.js developer and looking for a job, subscribe to <a href="https://www.getrevue.co/profile/govuejs">our mailing list.</a> Or if you are looking for a Vue.js developer, feel free to post your job requirements here in <a href="https://vuejobs.com/">vuejobs.com</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*5gcuct6rUWOC876lVoWBZA.png" /><figcaption>VueJobs.com</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=838a5d9ab03a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/vuejobs/create-a-global-event-bus-in-vue-js-838a5d9ab03a">Create a global event bus in Vue.js</a> was originally published in <a href="https://medium.com/vuejobs">VueJobs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>