addyosmani/aura — pull request #169 by tony (2012-11-24 18:40:50+00:00)
Title: pubsub + perms: wildcards, namespaces

Total overhaul of messaging + permissions in Aura. It's a work in progress. It should work in browser, with the exception of hashChange.

- Pubsub compatible w/ EventEmitter2.
- Permissions compatible w/ EventEmitter2.

Naming and conventions:

* 'subscriber' is the name of the widget sandbox.
* 'channel' is being converted to 'event'.

In the background:

- Sandboxes have their own pubsub in `pubsubs`. Where `pubsubs.calendar` is an EventEmitter instance for the `calendar` sandbox widget.
- Garbage collection: Upon a sandbox/widget being destroyed, the pubsub has `removeAllListeners()`, it null'd and then deleted.
- Most of the logic for permissions is inside the mediator / core.js.
- aura/permissions.js currently only holds a structure and accessor.
- Each pubsub reserves `perm.` namespace, which is populated from the sandbox's permission file. `perm` namespace is used as a validator so permissions can have full `*` and `**` support also.
- '*' without namespace is `.onAny`

If we are ok with this route, I need rewrite our unit tests and clean up things.

- Should permissions filter `on`, `emit`, or both?
- Do we want give sandbox'd widgets access to listen/broadcast inside themselves?
- Should sandboxWidgets be forced to emit only with the name of their sandbox?
- Should sandboxWidgets be forced to emit only with the name of their sandbox, *unless* otherwise specified by perms?
- Should sandboxWidgets have the name of their sandbox reserved for local pubsub?