geddy / model

Datastore-agnostic ORM in JavaScript
265 stars 55 forks source link

Make 'save' and 'update' events pass the instance as an argument #10

Open techwraith opened 12 years ago

techwraith commented 12 years ago

If I do:

geddy.model.Item.on('save', function (data) {
  // do shit
});

I expect data to be the data for the thing that was saved (with {saved: true, id: blah, etc.}.

I'll look into this one, but I wanted @mde's thoughts on this one.

techwraith commented 12 years ago

Looks like this will only work for non collection saves and updates. I'm ok with that. Collections are really hard to "eventify"

techwraith commented 12 years ago

It's either this or we implement an "afterSave" event that only fires when a single instance is saved and passes the saved data with it.

I need this for geddy's realtime stuff - the frontend needs to know the id's of the instances that it has.

mde commented 12 years ago

Okay, this is in master. Can you see if it behaves as expected?