It requires a bit of forethought to do it right. Basically, you have an
instance and you pass it options about which plugins it should use. Your
class has a way to register plugins on an instance or globally. Look at
FormValidator and it's Validator instances. A FormValidator has both global
validators and instance validators. The instance validators can overwrite
the global ones. It doesn't always work though. For HtmlTable the trick
would be that some plugins need to hook into events; when rows are added or
removed or altered, for example. All the places where the refactored
examples use this.previous() would require that the base class have some
sort of event that the plugin can hook into. It limits the things that
plugins can do, where refactoring generally doesn't.

On Tue, Aug 31, 2010 at 3:13 PM, Ryan Florence <[email protected]> wrote:

> On Aug 31, 2010, at 4:02 PM, Aaron Newton wrote:
>
> > If I went back and rewrote the HtmlTable stuff, I'd probably use a
> plugin-style pattern, but using Refactor works fine, too.
>
> Can you expand on this a bit?
>
> I'm about to dig in to SlideShow to add some "plugins" like a navigation
> piece, or a carousel, or touch events, etc. and haven't settled on how to do
> it.

Reply via email to