GeppettoJS/backbone.geppetto

Stop listening context

Closed this issue · 4 comments

Hi,

as I add a listener on the context to get the asynchronous result of a command, I would like to remove it as soon as I don't need it anymore.
Would it be possible to add a stopListen method bound on the backbone stopListening method?

Thanks.

Vincent.

@untemps : How about listenToOnce(), which would automatically remove the listener after one time.

See: #28

@geekdave : Sure, but it have to be implemented on the context object, right?

@untemps : Correct, this is not implemented yet. But you could temporarily work around it yourself like so:

Assuming you are working inside a Backbone View, which has a reference to a Context called myContext:

this.listenToOnce(this.myContext.vent, "someEvent", this.someCallback)

Will try to get this implemented soon. Let me know if the workaround does the trick for now. It's not the cleanest, since the Context's vent property is supposed to be "private".

@geekdave : Ok. I thought I could write this kind of workaround. I'm gonna try and I'll let you know.
Thanks a lot.