Read the statement by Michael Teeuw here.
Delay loading of one instance of a module and not another
-
I am trying to use two instances of https://github.com/philking98/MMM-horoscope to display the horoscope for Gemini and Sagittarius. I get the different signs displayed but the Gemini horoscope is duplicated under Sagittarius. I tried adding a delay but both of the instances appear to load at the same time. Is there a trick to slow one of them down so that hopefully it will pull the correct data? Thank you for taking a look at this.
{ // MMM-horoscope Gemini module: 'MMM-horoscope', position: 'top_right', config: { initialLoadDelay: 5000, sign: 'gemini', // Zodiac sign useTextIcon: false } }, { // MMM-horoscope Sagittarius module: 'MMM-horoscope', position: 'top_right', config: { sign: 'sagittarius', // Zodiac sign useTextIcon: false } },
-
@sdetweil Seems to be working great! Thank you very much for taking the time to make this a multi-instance module! Also great that you eliminated the need for npm install node-fetch@2. Even though I don’t know very much about java script, I understand it much better than these horoscopes :grinning_squinting_face:
-
@DDE12 this modules doesn’t support multiple instances…
to fix this the modulename.js needs to send some unique id with its request to the node_helper. we typically user this.identifier
then the node_helper sends this value back as part of the data
and then the modulenane.js checks if the returned value matches. because the sendSocketNotification from the node helper is a broadcast to all instances at the same time.
I just fixed my pythonPrint module for this very problem
-
Thank you for the advice. I looked at your module and some others that allow for multiple instances but could not get it to work. I looked at some of the requests for multiple instances in the original (https://github.com/morozgrafix/MMM-horoscope) and the author commented that it would require rebuilding the entire module.
As a work around, I cloned a second MMM-horoscope module and renamed the folder to MMM-horoscope2. Then renamed MMM-horoscope.js and MMM-horoscope.css to MMM-horoscope2.js and MMM-horoscope2.css. Then renamed all the .MMM-horoscope in the css to .MMM-horoscope2. Finally, I ran npm install in MMM-horoscope2 folder followed by npm install node-fetch@2. -
@DDE12 that’s the second approach
-
@DDE12 use my fork, which supports multiple instances
https://github.com/sdetweil/MMM-horoscope
to test, rename the old module folder to some other name
git clone and npm install for my module
change the module name of your additional instances to the same as the 1st (now my module)
if it fails, just rename my module folder out of the way,
put back the other module folder
and restore the module names in config.jsit was a tiny change, so I think it will work
-
@DDE12 I just added another update in case this module is used on a nodejs version below 18 to load a lib to support fetch
-
@sdetweil Seems to be working great! Thank you very much for taking the time to make this a multi-instance module! Also great that you eliminated the need for npm install node-fetch@2. Even though I don’t know very much about java script, I understand it much better than these horoscopes :grinning_squinting_face: