You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I often find myself with multiple places inside my more complicated views where I start and stop listening for events. I've put some serious thought into it, and would like add centralized declarative event registration to ampersand-view.
which is essentially -> this.listenTo(this.something, 'all', this.doSomething);
In addition, I would like to add some more behavior that I haven't fully mapped out. I would like to add the option of registering the event listener once an event has occurred e.g.
this.once('change:rendered', function () { this.listenTo(this.something, 'all', this.doSomething); });
It may need conditional start and stop, which I don't particularly like. I'm open to suggestions on a better way to do it.
ampersandEvents: [
{
start: 'change:rendered',
startCondition: function (model, value) { return value; }, // only starts if rendered is true
stop: 'change:remove',
stopCondition: function () { return true; }, // this is just to show the stop condition function.
object: this.something,
callback: this.doSomething,
name: 'all'
}
],
If we don't want to include this in ampersand-view I understand, I will likely release it as an extension in that case.
The text was updated successfully, but these errors were encountered:
I often find myself with multiple places inside my more complicated views where I start and stop listening for events. I've put some serious thought into it, and would like add centralized declarative event registration to ampersand-view.
e.g.
which is essentially ->
this.listenTo(this.something, 'all', this.doSomething);
In addition, I would like to add some more behavior that I haven't fully mapped out. I would like to add the option of registering the event listener once an event has occurred e.g.
this.once('change:rendered', function () { this.listenTo(this.something, 'all', this.doSomething); });
Something like:
It may need conditional start and stop, which I don't particularly like. I'm open to suggestions on a better way to do it.
If we don't want to include this in ampersand-view I understand, I will likely release it as an extension in that case.
The text was updated successfully, but these errors were encountered: