Closed weepy closed 10 years ago
we could utilize the top-level constructor events instead of adding a bunch of adhoc things like before/after/initialize
ah ok so something like :
User = model('User')
User.on('construct', function(user) {
// do things with user
})
with this somewhere:
this.model.emit('construct', this)
yeah, not sure what the event name should be but something like that
initialize
?
If you went down the event road, how would you handle changes to the model that may be async? Something like:
User = model('User')
User.on('init', function(user, next) {
// do things with user
next()
})
@RGBboy you can't magically block a constructor anyway, so that isn't possible
My use case for this would be when you want nested models. (Using the event for performing smth similar to the JSON.parse reviver
parameter)
ie :