momentohq / client-sdk-javascript

Official JavaScript SDK for Momento Serverless Cache
Apache License 2.0
55 stars 20 forks source link

chore: refactor AbstractPubSubClient to ensure safe use of required vars #1399

Closed cprice404 closed 1 month ago

cprice404 commented 1 month ago

This commit contains no functional changes; simply refactors the AbstractPubSubClient to stop leaking out member variables to its subclasses. The way it was previously defined, there were several member variables that were required to be initialized by the child classes, which, if you did not initialize them would result in a runtime error instead of a compile-time error. This commit changes the variables to be private, provides protected accessor functions as needed, and creates a constructor function that requires them to be passed in at initialization time. This moves any related bugs from run time to compile time and makes it simpler to reason about the ownership of the variables.