markdalgleish/bespoke.js — pull request #50 by neochief (2014-12-20 10:19:52+00:00)
Title: Destroying the presentation from 3rd party code.

First of all, thank you very much for this great library.

I've been using it for my project, which involves showing multiple presentations on one page. It looks like an index of presentations, user can play them in sequential order and I'd like to make it in very seamless way, without page reload. So far, everything was good, but I noticed that some plugins like bespoke-hash bind some handlers to the window object events, and don't unbind them when bespoke instance gets destroyed (and later replaced with a new one). And there's no clear way for such plugins to unbind their handlers, since there's no destroy event in the core library.

I propose to add the destroy() method, which will fire the 'destroy' event prior to the presentation element removal. This way all plugin developers would know that there's a standard event, which they could handle and implement the clean-up.

If you find this reasonable and decide to accept this (or similar) code, I promise to create pull requests for all popular bespoke plugins with destroy handlers implementations.

Thanks!