MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    setTimeout called only once in node_helper.js

    Development
    2
    3
    1754
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      bobbob601 last edited by

      Hi,

      I’m getting crazy with this, read stackoverflow, articles and still I cannot success to do a simple timeout.
      In the last version of my plugin,
      this code is called once and in the console I’ll see only one “boo”

      setTimeout(function () {
        console.log('boo')
      }, 100);
      

      Then nothing in the console, others modules work fine, but not mine (it works but never refreshs)

      here is the full code

      const NodeHelper = require("node_helper");
      const forge = require('node-forge');
      const unirest = require('unirest');
      
      module.exports = NodeHelper.create({
      
      		updateTimer:"",
      		start: function () {
      	    		this.started = false;
      			console.log("MMM-Ratp- NodeHelper started");
      	  	},
      
      
      		socketNotificationReceived: function(notification, payload) {
      			
      			
      setTimeout(function () {
        console.log('boo')
      }, 100);
      
      		}
      

      what could causes this ? I tried everything, started from scratch but always the same issue

      strawberry 3.141 1 Reply Last reply Reply Quote 0
      • strawberry 3.141
        strawberry 3.141 Project Sponsor Module Developer @bobbob601 last edited by

        @bobbob601 a timeout is only fired once, what you want is an interval so replace setTimeout with setInterval

        Please create a github issue if you need help, so I can keep track

        1 Reply Last reply Reply Quote 0
        • B
          bobbob601 last edited by

          I’m ashamed…

          thanks!

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Enjoying MagicMirror? Please consider a donation!
          MagicMirror created by Michael Teeuw.
          Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
          This forum is using NodeBB as its core | Contributors
          Contact | Privacy Policy