Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Observable #7

Open
benbucksch opened this issue Feb 16, 2024 · 0 comments
Open

Support for Observable #7

benbucksch opened this issue Feb 16, 2024 · 0 comments

Comments

@benbucksch
Copy link
Owner

On the server

If the server is sending an object that implements Observable (or has a subscribe() method), then:

  • Send the object as type observable instead of plainObject
  • Send the values of all public properties of the object. Also, the values of all public getters.
  • (Make a function isPrivateProperty(propertyName: string) which skips all properties starting with _, starting with #, and possibly others later.)
  • Let the server subscribe to the object.
  • Once the subscriber is called, send the updated property values to the client.

On the client

If the client receives an object of type observable,

  • the client creates a stub (e.g. RemoteObservable), similar to the plain object, but also sets all the properties that the server sent.
  • The object implements Observable with a subscribe() method and remembers the subscribers.
  • If the server sends updated property values, the client updates the local object, and then calls the local subscribers.

Object lifetime

Pay attention for object lifetime.

  • We don't want the client to hold on to objects which don't exist on the server anymore. (Hopefully, the collection observers will take care of that.) In other words, we should not have wild pointers.
  • We don't want the server or client to keep objects alive which represent base objects that have been destroyed. In other words, we should not leak.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant