cobbdb / harmony

Simplify your DFP business logic.
MIT License
25 stars 5 forks source link

Allow slots to join multiple groups #36

Closed cobbdb closed 6 years ago

cobbdb commented 8 years ago

Use-case here is -

given slot RP01 exists in groups nav-menu and full-width.

Both of the following calls should affect RP01:

harmony.show.group('nav-menu');
harmony.show.group('full-width');
cobbdb commented 8 years ago

This could lead into more advanced slot selection using css syntax - leverage Sizzle maybe?

harmony('.some-group #some-slot').action(); // applies to this slot
harmony('#some-slot').action(); // applies to this slot
harmony('.some-other-group #some-slot').action(); // applies to this slot
harmony('.some-group').action(); // applies to all slots in group
cobbdb commented 8 years ago

Can already access a single slot with harmony.slot(), but the only functionality missing is apply an action to all slots in a group:

harmony.group('some-group').action();

Would require inversion of control with how actions are applied to slots. Right now global applies to the slot, but this change would require that the slot owns the action. EX - instead of:

harmony.show.slot('RP01');

... would become this ...

harmony.slot('RP01').show();
cobbdb commented 8 years ago

Inverting control of slot actions isn't necessary here, in fact the way it is now is the correct flow of control and to invert would be an anti-pattern.

Updating issue description with more detailed use-case.