README.md in flirt-0.0.4 vs README.md in flirt-0.1.0

- old
+ new

@@ -27,18 +27,19 @@ ``` ## Usage -To publish an event: +###To publish an event: ```ruby +event_data = { fruit: 'apple' } Flirt.publish :picked, event_data ``` -To subscribe: +###To subscribe: ```ruby class MyListener def initialize Flirt.subscribe self, :picked, with: :picked_callback @@ -48,11 +49,11 @@ puts "The #{event_data[:fruit]} has been picked" end end ``` -To unsubscribe: +###To unsubscribe: ```ruby Flirt.unsubscribe self, :picked, with: :picked_callback end ``` @@ -92,11 +93,11 @@ end ``` ```unsubscribe_from``` can technically be used in the class context, but probably doesn't have as much use. -Flirt defaults to 'enabled'. Switch Flirt off: +###Flirt defaults to 'enabled'. Switch Flirt off: ```ruby Flirt.disable ``` @@ -104,29 +105,50 @@ ```ruby Flirt.enable ``` -TODO: Disable only a set of events: +Enabled status affects publishing only, listeners can still be added and will be +remembered. No listeners will be removed. +###Disable only a set of events: + ```ruby Flirt.disable only: [:pancake_cooked, :picked] ``` -TODO: Enable only a set of events: +###Enable only a set of events: ```ruby Flirt.enable only: [:topping_added, :pancake_flipped] ``` -Enabled status affects broadcast/publish, listeners can still be added and will be -remembered. No listeners will be removed. +Disabling and enabling sets of events is not cumulative. The new set of events will overwrite all previous calls. +For example: -Clear all listeners: +```ruby +Flirt.disable only: [:pancake_cooked, :picked] +Flirt.disable only: [:flipped] +``` +The above code will leave only ```:flipped``` disabled. + ```ruby +Flirt.enable only: [:flipped, :picked] +Flirt.disable only: [:flipped] +``` + +The above code will also leave only ```:flipped``` disabled. + +Calling ```Flirt.enable``` or ```Flirt.disable``` will clear any previously set enabled or disabled events. + +###Clear all listeners: + +```ruby Flirt.clear ``` + +This operation cannot be undone. ## Contributing 1. Fork it ( https://github.com/[my-github-username]/flirt/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`)