maccman/spine — pull request #266 by mitchlloyd (2012-04-07 23:08:48+00:00)
Title: Change the behavior of refresh so that it always passes the refreshed models

I'm submitting this patch to change the refresh method so that it always passes the refreshed models. For some reason when {clear: true} is passed the 'refresh' event is triggered with false. Is there a use case for this? I think most would expect the refreshed models to always be passed along no matter what "clear" is set to.

If someone needs to know whether "clear" was set when binding to the 'refresh' event, it would make more sense to me to add an options object to the trigger. Here is my current use case is for the attribute tracking extension that I made which should show the problem that I'm running into:

AttributeTracking =
extended: ->
@oldAttributes = {}

@bind 'refresh create', (models) =>
# Spine's behavior for refresh with {clear: true} passes false so we need
# this fix.
models or= @all()

# models could be an array of models or one model.
if models.length?
@setOldAttributes(model) for model in models
else
@setOldAttributes(models)