MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. sdillard
    3. Posts
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    S
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Groups 0

    Posts

    Recent Best Controversial
    • RE: Getting error using rss-parser

      @sdetweil Thanks for the response. I figured it out (just needed a fresh look, I guess). It didn’t have to do with scoping or binding – I was using parser.parse() when it should be parser.parseURL().

      Just more for breadcrumbs for anyone reading this later, while it is true that it is important to scope a variable to self and do as you suggest, it is actually completely unnecessary in some cases and just leads to confusing code. If in my method I declare a require and then use that variable and no other method ever needs to use that variable, then scoping it to self just increases the size of the object unnecessarily since it can’t be garbage collected. And if I declare a require statement at the top of my module, I am creating a global variable, which can be dangerous and bad if I don’t understand what that means but is the right way if it is not an instance variable of the object.

      I don’t want to seem unappreciative – I do really appreciate your saying this as it made me requestion my code…

      posted in Troubleshooting
      S
      sdillard
    • Getting error using rss-parser

      I’m creating a newer RSS feed module that updates regularly and rotates between different feeds. I think I am all good, but I am using rss-parser, and it doesn’t seem to be creating a new object when invoked.
      At the top of my node_helper.js file, I have

      var NodeHelper = require("node_helper");
      var RssParser = require("rss-parser");
      

      I’ve tried three ways to create a new parser object, but I always get parser.parse is undefined, which tells me that it isn’t creating the object, or the reference is invalid for some reason. I need a line to create the parser, like this:

      var parser = new RssParser();
      

      Here’s what I’ve tried:

      1. including this line below the require lines (see above),
      2. including in the socketNotificationReceived method, and
      3. creating a getter (see below)
      getParser: function() {
        if (this.parser === undefined) {
          this.parser = new RssParser();
        }
        return this.parser;
      }
      

      No luck! The documentation for rss-parser is clear and it works great when I run a local node script that just reads a feed.

      Help appreciated – I feel like I am missing something obvious…

      posted in Troubleshooting
      S
      sdillard
    • 1 / 1