loteixeira/AS3console — pull request #1 by creynders (2012-04-20 09:51:09+00:00)
Title: Multiple instances

Hi Lucas,

I found your AS3 console today, and I think it's great since it's so small and easy to use. There's one thing though, since it uses the singleton pattern it's not possible to create multiple instances. Apart from my distaste for singletons (they're hard to unit test etc.) I'm also using it in a project where I need to be able to create multiple console windows (that way I can channel my logging output to different console windows)

Since it's not really hard to extract the core functionality out of it, that's exactly what I did. I created a separate class ```ConsoleCore``` which can normally be instantiated. The ```Console``` class still behaves __EXACTLY__ as before. It's still a singleton with static config members, but just creates a single instance of the ```ConsoleCore``` class. All members are accessors that wrap that single instance's members.
In other words, it's fully backwards compatible with version 0.3.5. I did up the version number to 0.4.0, since my changes add something to the public API and following the semver.org rules the minor version should be incremented in that case (on the other hand it's stil < 1.0, so you can do as you please actually).

I tried to leave the code as much as-is, except for one optimization: I swapped all anonymous event listeners to named ones, since anon functions are REALLY slow.
The reason why I moved all default static values to ```ConsoleCore``` instead of leaving them in ```Console``` is because I didn't want any dependency from ```ConsoleCore``` towards ```Console```.

I hope you like the addition and that I didn't introduce any new bugs. I didn't complete the asdocs for the new class yet, if you accept the pull request let me know and I'll finish the ASDocs.