Unset Session Variables for Meteor.js Hot Code Reload

How did you cancel the session variable when reloading the hot code?

I have the following subscription code and you want to execute Session.set('score', '')when the hot code reloads.

Deps.autorun( function() {
    Meteor.subscribe('score', Meteor.userId(), function() {
        Session.set('score', new Date().getTime())
    })
})
+4
source share
2 answers

Session.keys is an object, so you can remove the “score”, as it does at startup.

Meteor.startup(function () {
    delete Session.keys['score'];
});
+2
source

You can use the private Reload._onMigrate API to have finer control over what happens during a hot code reload. There is a screencast on this topic.

https://www.eventedmind.com/tracks/meteor-core-systems/using-a-custom-onmigrate-api

+2
source

Source: https://habr.com/ru/post/1527064/


All Articles