Skip to content

Instantly share code, notes, and snippets.

@krisleech
Created February 6, 2017 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krisleech/ca032a6cb327eedd37cae28f602e0ef8 to your computer and use it in GitHub Desktop.
Save krisleech/ca032a6cb327eedd37cae28f602e0ef8 to your computer and use it in GitHub Desktop.
wisper subscribers with namespace
class MyListener
   on_event "recruitment/monthly_total_updated" do |payload|
     # ...
   end

end

broadcast("recruitment/monthly_total_updated", payload)

instead of

class MyListener
  def recruitment__monthly_total_updated(payload)
    # ...
   end
 end
 
 broadcast(:recruitment__monthly_total_update, payload) # double underscore used to seperate namespace and event name

When an event name is a symbol then it could still be matched to on_event("recruitment/...").

@krisleech
Copy link
Author

on_event would need to be eval'd in context of object so it has access to private methods etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment