derbyjs / racer

Realtime model synchronization engine for Node.js
1.18k stars 117 forks source link

Model events EventEmitter initialization question #226

Closed qlonik closed 3 months ago

qlonik commented 9 years ago

Hello, derbyjs developers team. First of all, thank you for creating such a great module!

I was reading through the source code of the project and I find the way how you initialize Model class very interesting and creating. Having an array of initializers where each receives instance of model class when it is being initialized is new. I have never seen anything like that in other libraries.

What do you think are advantages and disadvantages to such an approach?

However, my main question is about events initializer. In the events file on line 18 you are initializing current instance with EventEmitter constructor. This EventEmitter constructor is being bound to this variable, which is in that context is a reference to the initializer function, not to the actual model instance. Why was it made this way? Shouldn't EventEmitter be bound to the model variable (EventEmitter.call(model))? Especially, considering the fact that a bit later on line 37 you are copying all functions from EventEmitter prototype to Model prototype.

Thank you for your reply and a great module.

craigbeck commented 3 months ago

Thanks for your contributing your issue.

We have recently been actively updating the Derby and Racer packages, and both repos are now in Typescript and published with types on npm. As we have quite a few old issues open we have made the decision to close out of date issues.

If this issue still matters to you we encourage reproducing against the current versions of the repo and opening a new issue.