<?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: Mateus Ragazzi</title>
    <description>The latest articles on DEV Community by Mateus Ragazzi (@mateusragazzi).</description>
    <link>https://dev.to/mateusragazzi</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%2F3351283%2F9d331828-9408-4fcc-ab23-c38297b29c5f.jpg</url>
      <title>DEV Community: Mateus Ragazzi</title>
      <link>https://dev.to/mateusragazzi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mateusragazzi"/>
    <language>en</language>
    <item>
      <title>Building Reactive Lists with Meteor and Blaze</title>
      <dc:creator>Mateus Ragazzi</dc:creator>
      <pubDate>Tue, 23 Sep 2025 14:42:20 +0000</pubDate>
      <link>https://dev.to/quave/building-reactive-lists-with-meteor-and-blaze-54i9</link>
      <guid>https://dev.to/quave/building-reactive-lists-with-meteor-and-blaze-54i9</guid>
      <description>&lt;p&gt;Hey there! If you're diving into building real-time apps, you know how crucial it is to keep your UI up-to-date. At &lt;a href="https://quave.dev" rel="noopener noreferrer"&gt;Quave&lt;/a&gt;, we're big fans of &lt;a href="https://www.meteor.com" rel="noopener noreferrer"&gt;Meteor JS&lt;/a&gt; and its ecosystem to make this happen.&lt;/p&gt;

&lt;p&gt;One of available tools is &lt;a href="https://www.blazejs.org" rel="noopener noreferrer"&gt;Blaze JS&lt;/a&gt;, which gives you a great platform for creating real-time apps. While Blaze isn't recommended for new projects (the Meteor team now focuses on React and Vue.js), you'll likely encounter it in legacy codebases.&lt;/p&gt;

&lt;p&gt;Today, I'm gonna walk you through how to build a reliable and reactive list using Blaze's &lt;code&gt;#let&lt;/code&gt; directive. Trust me, this will save you from some async nightmares when working with existing Blaze applications!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fytt755vqprek2303v1em.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fytt755vqprek2303v1em.png" alt="Reactive lists in Blaze with the #let directive made simple" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem with Lists
&lt;/h2&gt;

&lt;p&gt;Lists are everywhere in apps — user lists, task lists, etc. Keeping them updated in real-time when data changes can be tricky sometimes. You might be tempted to use a &lt;code&gt;ReactiveVar&lt;/code&gt; to manage your list's state, and that's not a bad idea. But Blaze's &lt;code&gt;#let&lt;/code&gt; directive can make your life &lt;em&gt;way&lt;/em&gt; easier by simplifying how you handle reactive data sources. Let's see how it works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reactive List with &lt;code&gt;#let&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Imagine you've got a list of users you want to display, and it needs to update instantly when a new user is added or one gets updated. Instead of using &lt;code&gt;ReactiveVar&lt;/code&gt; or dealing with async and sync operations, Blaze's &lt;code&gt;#let&lt;/code&gt; lets you declaratively bind a reactive data source to a variable in your template.&lt;/p&gt;

&lt;p&gt;To achieve that, you need to set up a helper in your JavaScript to fetch the data reactively. For our user list, we'll use Meteor's &lt;code&gt;Users&lt;/code&gt; collection and sort it by creation date:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;Template&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;myTemplate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;helpers&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="nf"&gt;myList&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;Users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;createdAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This helper gets all users from the &lt;code&gt;Users&lt;/code&gt; collection, sorted by the most recent first. The &lt;code&gt;fetch()&lt;/code&gt; method ensures we get an array of documents that Blaze can work with.&lt;/p&gt;

&lt;p&gt;Now, in your Blaze template, you use the &lt;code&gt;#let&lt;/code&gt; directive to bind this helper to a variable called &lt;code&gt;list&lt;/code&gt;. Then, you can iterate over it or check its length to display the right UI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;template&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"myTemplate"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  {{#let list=myList}}
    {{#if list.length}}
      &lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
        {{#each user in list}}
          &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;{{user.name}}&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
        {{/each}}
      &lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
    {{else}}
      &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;No users found.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    {{/if}}
  {{/let}}
&lt;span class="nt"&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's what's cool about this setup:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Since &lt;code&gt;myList&lt;/code&gt; is backed by a Meteor &lt;code&gt;find&lt;/code&gt; query, it's reactive. If a new user is added to the &lt;code&gt;Users&lt;/code&gt; collection, the list updates automatically, and Blaze re-renders the UI.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;#let&lt;/code&gt; directive lets you assign the helper's result to a variable (&lt;code&gt;list&lt;/code&gt;) that you can use throughout the template. It keeps your code readable and avoids messy nested helper calls.&lt;/li&gt;
&lt;li&gt;By using &lt;code&gt;list.length&lt;/code&gt;, you can easily toggle between showing the list or a "No users found" message, avoiding using a helper to do so.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Should I use &lt;code&gt;#let&lt;/code&gt; or &lt;code&gt;ReactiveVar&lt;/code&gt;?
&lt;/h2&gt;

&lt;p&gt;The choice between &lt;code&gt;#let&lt;/code&gt; with reactive helpers and &lt;code&gt;ReactiveVar&lt;/code&gt; often comes down to your specific use case: &lt;code&gt;#let&lt;/code&gt; excels for straightforward data binding from collections, while &lt;code&gt;ReactiveVar&lt;/code&gt; shines when you need to manage derived state or implement custom reactive logic that doesn't directly map to a database query.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;Building reactive lists doesn't have to be a nightmare, specially on legay code bases. With Meteor and Blaze's &lt;code&gt;#let&lt;/code&gt; directive, you can create real-time UIs with minimal code.&lt;/p&gt;

&lt;p&gt;Got questions or want to share your own Meteor tips? Drop a comment below, and let's keep the conversation going!&lt;/p&gt;

</description>
      <category>meteor</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>blazejs</category>
    </item>
  </channel>
</rss>
