In the Node Meteor environment, I am using a settings singleton like this:
class settingsClass {
partner = undefined;
setPartner(name: string) {
return this.partner = name;
}
getPartner() {
if (this.partner) return this.partner
throw 'Partner is unknown'
}
}
export let Settings = new settingsClass()
I found out that this setting is shared between clients and method calls. What other option is there for a client and method call separated “global” namespace? I want to manage some environment without passing all via parameters, etc.
Based on the documentation the methods this conext
Inside your method invocation, this is bound to a method invocation object, which provides the following:
So I might extend this object with my variable. But how can I access it from inside some function, without passing it all the way down?
function somecall() {
... ? // how to access method invocation object's property partner?
}
Meteor.methods({
'setpartner'(name) {
// @ts-ignore
this.partner = name
somecall()
}
})