OOP and Meteor server/client dichotomy


#1

Hello Everybody,

I want to create an object whom existance is split between client and server.

 class SpaceClock{
  constructor(timeZone){
   this._timeZone = timeZone;

  }

  getTime{
   // return the local time on a given planet
  }
 }

Let’s say I want to:

  1. Instantiate on the server, then pass the object to the client.

or

  1. Instantiate on the client, then pass the object to the server.

For the first problem I would have a Meteor Method that return an instance of the object, for the second problem I would pass the object in a Meteor Method to the server, but I think both solutions are ugly.

Is there a smarter way to share the existence of an object between client and server?